@sqb/connect 5.0.4 → 5.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/client/sqb-connection.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Query } from '@sqb/builder';
|
|
1
|
+
import { isQuery, Query } from '@sqb/builder';
|
|
2
2
|
import assert from 'assert';
|
|
3
3
|
import _debug from 'debug';
|
|
4
4
|
import { TaskQueue } from 'power-tasks';
|
|
@@ -87,7 +87,22 @@ export class SqbConnection extends TypedEventEmitterClass(AsyncEventEmitter) {
|
|
|
87
87
|
async execute(query, options) {
|
|
88
88
|
if (!this._intlcon)
|
|
89
89
|
throw new Error(`Can't execute query, because connection is released`);
|
|
90
|
-
|
|
90
|
+
try {
|
|
91
|
+
return await this._tasks
|
|
92
|
+
.enqueue(() => this._execute(query, options))
|
|
93
|
+
.toPromise();
|
|
94
|
+
}
|
|
95
|
+
catch (err) {
|
|
96
|
+
if (err.stack)
|
|
97
|
+
err.stack = err.stack
|
|
98
|
+
.split('\n')
|
|
99
|
+
.filter((line) => !(line.includes('/power-tasks/') ||
|
|
100
|
+
line.includes(':internal') ||
|
|
101
|
+
line.includes('Task._executeFn') ||
|
|
102
|
+
line.includes('SqbConnection._')))
|
|
103
|
+
.join('\n');
|
|
104
|
+
throw err;
|
|
105
|
+
}
|
|
91
106
|
}
|
|
92
107
|
getRepository(entity, opts) {
|
|
93
108
|
let ctor;
|
|
@@ -253,7 +268,7 @@ export class SqbConnection extends TypedEventEmitterClass(AsyncEventEmitter) {
|
|
|
253
268
|
fetchAsString: options.fetchAsString,
|
|
254
269
|
};
|
|
255
270
|
request.ignoreNulls = request.ignoreNulls && request.objectRows;
|
|
256
|
-
if (query
|
|
271
|
+
if (isQuery(query)) {
|
|
257
272
|
if (this._intlcon.onGenerateQuery)
|
|
258
273
|
this._intlcon.onGenerateQuery(request, query);
|
|
259
274
|
const q = query.generate({
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { And, In, Param, Select, TableName } from '@sqb/builder';
|
|
2
|
+
import { isAssociationNode } from '../../type-guards.js';
|
|
2
3
|
import { AssociationNode } from '../model/association-node.js';
|
|
3
4
|
import { EntityMetadata } from '../model/entity-metadata.js';
|
|
4
5
|
import { isAssociationField, isColumnField, isEmbeddedField, resolveEntityForEmbeddedField, } from '../util/orm.helper.js';
|
|
@@ -26,7 +27,7 @@ export class FindCommand {
|
|
|
26
27
|
static async create(source, opts = {}) {
|
|
27
28
|
let command;
|
|
28
29
|
let listingEntity;
|
|
29
|
-
if (source
|
|
30
|
+
if (isAssociationNode(source)) {
|
|
30
31
|
const node = source;
|
|
31
32
|
listingEntity = await node.resolveTarget();
|
|
32
33
|
const resultEntity = await node.getLast().resolveTarget();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { And,
|
|
1
|
+
import { And, isSqlElement, Param, TableName, Update } from '@sqb/builder';
|
|
2
2
|
import { EntityMetadata } from '../model/entity-metadata.js';
|
|
3
3
|
import { checkEnumValue, isColumnField, isEmbeddedField, resolveEntityForEmbeddedField, } from '../util/orm.helper.js';
|
|
4
4
|
import { prepareFilter } from './command.helper.js';
|
|
@@ -63,7 +63,7 @@ export class UpdateCommand {
|
|
|
63
63
|
if (col.noUpdate)
|
|
64
64
|
continue;
|
|
65
65
|
const fieldName = prefix + col.fieldName + suffix;
|
|
66
|
-
if (v
|
|
66
|
+
if (isSqlElement(v)) {
|
|
67
67
|
ctx.queryValues[fieldName] = v;
|
|
68
68
|
continue;
|
|
69
69
|
}
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sqb/connect",
|
|
3
3
|
"description": "Multi-dialect database connection framework written with TypeScript",
|
|
4
|
-
"version": "5.0.
|
|
4
|
+
"version": "5.0.5",
|
|
5
5
|
"author": "Panates",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@jsopen/objects": "^2.2.
|
|
8
|
+
"@jsopen/objects": "^2.2.3",
|
|
9
9
|
"debug": "^4.4.3",
|
|
10
10
|
"doublylinked": "^2.5.6",
|
|
11
11
|
"fast-tokenizer": "^1.9.0",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"tslib": "^2.8.1"
|
|
22
22
|
},
|
|
23
23
|
"peerDependencies": {
|
|
24
|
-
"@sqb/builder": "^5.0.
|
|
24
|
+
"@sqb/builder": "^5.0.5",
|
|
25
25
|
"reflect-metadata": "^0.2.2"
|
|
26
26
|
},
|
|
27
27
|
"type": "module",
|
package/type-guards.d.ts
ADDED
package/type-guards.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { AssociationNode } from './orm/model/association-node.js';
|
|
2
|
+
export function isAssociationNode(v) {
|
|
3
|
+
if (!(v && typeof v === 'object'))
|
|
4
|
+
return false;
|
|
5
|
+
const proto = Object.getPrototypeOf(v);
|
|
6
|
+
return (typeof proto.getFirst === 'function' &&
|
|
7
|
+
typeof proto.getLast === 'function' &&
|
|
8
|
+
typeof proto.returnsMany === 'function');
|
|
9
|
+
}
|