@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 CHANGED
@@ -1 +1,2 @@
1
- export {};
1
+ import { Query } from '@sqb/builder';
2
+ import { DataType, } from './types.js';
@@ -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';
@@ -1,3 +1,4 @@
1
+ import { Query } from '@sqb/builder';
1
2
  export class SQBError extends Error {
2
3
  cause;
3
4
  queryOptions;
package/client/types.js CHANGED
@@ -1 +1,2 @@
1
+ import { DataType } from '@sqb/builder';
1
2
  export { DataType } from '@sqb/builder';
@@ -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 = this.converter;
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 empty objects
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 function (p) {
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
- })(prop);
171
+ });
172
172
  promises.push(promise);
173
173
  }
174
174
  else if (isObjectProperty(prop)) {
175
- promises.push(this._iterateForNested(prop.converter, connection, fields, rows, result));
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,3 +1,4 @@
1
+ import { EmbeddedFieldMetadata } from '../model/embedded-field-metadata.js';
1
2
  import { EntityMetadata, } from '../model/entity-metadata.js';
2
3
  import { applyMixins } from '../util/apply-mixins.js';
3
4
  export function Entity(options) {
@@ -1 +1 @@
1
- export {};
1
+ import { AssociationNode } from './association-node.js';
@@ -1 +1 @@
1
- export {};
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) {
@@ -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.2",
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.2",
24
+ "@sqb/builder": "^5.0.3",
25
25
  "reflect-metadata": "^0.2.2"
26
26
  },
27
27
  "type": "module",