@sqb/connect 5.0.2 → 5.0.3
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/adapter.js +2 -1
- package/client/sqb-client.js +1 -1
- package/client/sqb-error.js +1 -0
- package/client/types.js +1 -0
- package/orm/commands/command.helper.js +2 -1
- package/orm/commands/count.command.js +2 -1
- package/orm/commands/delete.command.js +2 -1
- package/orm/commands/find.command.js +2 -2
- package/orm/commands/row-converter.js +5 -4
- package/orm/commands/update.command.js +1 -0
- package/orm/decorators/entity.decorator.js +1 -0
- package/orm/model/association-field-metadata.js +1 -1
- package/orm/model/column-field-metadata.js +1 -1
- package/orm/model/entity-metadata.js +1 -0
- package/orm/repository.class.js +2 -0
- package/package.json +2 -2
package/client/adapter.js
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import { Query } from '@sqb/builder';
|
|
2
|
+
import { DataType, } from './types.js';
|
package/client/sqb-client.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import _debug from 'debug';
|
|
2
|
-
import { createPool, PoolState, } from 'lightning-pool';
|
|
2
|
+
import { createPool, Pool as LightningPool, PoolState, } from 'lightning-pool';
|
|
3
3
|
import { coerceToBoolean, coerceToInt } from 'putil-varhelpers';
|
|
4
4
|
import { AsyncEventEmitter, TypedEventEmitterClass } from 'strict-typed-events';
|
|
5
5
|
import { EntityMetadata } from '../orm/model/entity-metadata.js';
|
package/client/sqb-error.js
CHANGED
package/client/types.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { And, Eq, Exists, Field, InnerJoin, isCompOperator, isLogicalOperator, LeftOuterJoin, OperatorType, Or, Raw, Select, } from '@sqb/builder';
|
|
1
|
+
import { And, Eq, Exists, Field, InnerJoin, isCompOperator, isLogicalOperator, LeftOuterJoin, LogicalOperator, OperatorType, Or, Raw, Select, } from '@sqb/builder';
|
|
2
|
+
import { AssociationNode } from '../model/association-node.js';
|
|
2
3
|
import { EntityMetadata } from '../model/entity-metadata.js';
|
|
3
4
|
import { isAssociationField, isColumnField, isEmbeddedField, resolveEntityForEmbeddedField, } from '../util/orm.helper.js';
|
|
4
5
|
export async function joinAssociationGetFirst(joinInfos, association, parentAlias, innerJoin) {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { And, Count, Select, TableName } from '@sqb/builder';
|
|
1
|
+
import { And, Count, LogicalOperator, Select, TableName } from '@sqb/builder';
|
|
2
|
+
import { EntityMetadata } from '../model/entity-metadata.js';
|
|
2
3
|
import { prepareFilter } from './command.helper.js';
|
|
3
4
|
export class CountCommand {
|
|
4
5
|
// istanbul ignore next
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { And, Delete, TableName } from '@sqb/builder';
|
|
1
|
+
import { And, Delete, LogicalOperator, TableName } from '@sqb/builder';
|
|
2
|
+
import { EntityMetadata } from '../model/entity-metadata.js';
|
|
2
3
|
import { prepareFilter } from './command.helper.js';
|
|
3
4
|
export class DeleteCommand {
|
|
4
5
|
// istanbul ignore next
|
|
@@ -2,7 +2,7 @@ import { And, In, Param, Select, TableName } from '@sqb/builder';
|
|
|
2
2
|
import { AssociationNode } from '../model/association-node.js';
|
|
3
3
|
import { EntityMetadata } from '../model/entity-metadata.js';
|
|
4
4
|
import { isAssociationField, isColumnField, isEmbeddedField, resolveEntityForEmbeddedField, } from '../util/orm.helper.js';
|
|
5
|
-
import { parseFieldsProjection, } from '../util/parse-fields-projection.js';
|
|
5
|
+
import { FieldsProjection, parseFieldsProjection, } from '../util/parse-fields-projection.js';
|
|
6
6
|
import { joinAssociationGetLast, prepareFilter, } from './command.helper.js';
|
|
7
7
|
import { RowConverter } from './row-converter.js';
|
|
8
8
|
const SORT_ORDER_PATTERN = /^([-+])?(.*)$/;
|
|
@@ -151,7 +151,7 @@ export class FindCommand {
|
|
|
151
151
|
maxSubQueries: this.maxSubQueries - 1,
|
|
152
152
|
maxEagerFetch: this.maxEagerFetch,
|
|
153
153
|
});
|
|
154
|
-
findCommand.converter.parent =
|
|
154
|
+
findCommand.converter.parent = converter;
|
|
155
155
|
await findCommand.filter(In(targetCol.name, Param(parentField)));
|
|
156
156
|
const sort = sortFields && extractSubFields(colNameLower, sortFields);
|
|
157
157
|
await findCommand.addFields({
|
|
@@ -65,7 +65,7 @@ export class RowConverter {
|
|
|
65
65
|
if (!this.keys)
|
|
66
66
|
return result;
|
|
67
67
|
await this._iterateForNested(this, connection, fields, rows, result);
|
|
68
|
-
// Return only non
|
|
68
|
+
// Return only non-empty objects
|
|
69
69
|
return result.filter(x => !!x);
|
|
70
70
|
}
|
|
71
71
|
_rowToObject(executor, fields, row) {
|
|
@@ -123,7 +123,7 @@ export class RowConverter {
|
|
|
123
123
|
if (!(prop.paramValues && prop.paramValues.length))
|
|
124
124
|
continue;
|
|
125
125
|
const resultType = this.resultType;
|
|
126
|
-
const promise = (async
|
|
126
|
+
const promise = Promise.resolve(prop).then(async (p) => {
|
|
127
127
|
const findCommand = p.findCommand;
|
|
128
128
|
let fld;
|
|
129
129
|
const map = new Map();
|
|
@@ -168,11 +168,12 @@ export class RowConverter {
|
|
|
168
168
|
}
|
|
169
169
|
}
|
|
170
170
|
}
|
|
171
|
-
})
|
|
171
|
+
});
|
|
172
172
|
promises.push(promise);
|
|
173
173
|
}
|
|
174
174
|
else if (isObjectProperty(prop)) {
|
|
175
|
-
|
|
175
|
+
const subResult = result.map(r => r[propKey]).filter(x => x);
|
|
176
|
+
promises.push(this._iterateForNested(prop.converter, connection, fields, rows, subResult));
|
|
176
177
|
}
|
|
177
178
|
}
|
|
178
179
|
await Promise.all(promises);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { And, Param, SqlElement, TableName, Update } from '@sqb/builder';
|
|
2
|
+
import { EntityMetadata } from '../model/entity-metadata.js';
|
|
2
3
|
import { checkEnumValue, isColumnField, isEmbeddedField, resolveEntityForEmbeddedField, } from '../util/orm.helper.js';
|
|
3
4
|
import { prepareFilter } from './command.helper.js';
|
|
4
5
|
export class UpdateCommand {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import { AssociationNode } from './association-node.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import { DataType } from '@sqb/builder';
|
|
@@ -2,6 +2,7 @@ import { DataType } from '@sqb/builder';
|
|
|
2
2
|
import { ENTITY_METADATA_KEY } from '../orm.const.js';
|
|
3
3
|
import { isAssociationField, isColumnField, isEmbeddedField, } from '../util/orm.helper.js';
|
|
4
4
|
import { Association } from './association.js';
|
|
5
|
+
import { AssociationNode } from './association-node.js';
|
|
5
6
|
export var EntityMetadata;
|
|
6
7
|
(function (EntityMetadata) {
|
|
7
8
|
function define(ctor) {
|
package/orm/repository.class.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { LogicalOperator } from '@sqb/builder';
|
|
1
2
|
import { AsyncEventEmitter, TypedEventEmitterClass } from 'strict-typed-events';
|
|
3
|
+
import { FieldInfoMap } from '../client/field-info-map.js';
|
|
2
4
|
import { CountCommand } from './commands/count.command.js';
|
|
3
5
|
import { CreateCommand } from './commands/create.command.js';
|
|
4
6
|
import { DeleteCommand } from './commands/delete.command.js';
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
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.3",
|
|
5
5
|
"author": "Panates",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"dependencies": {
|
|
@@ -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.3",
|
|
25
25
|
"reflect-metadata": "^0.2.2"
|
|
26
26
|
},
|
|
27
27
|
"type": "module",
|