@mikro-orm/sql 7.0.0-dev.115 → 7.0.0-dev.116

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.
@@ -25,7 +25,8 @@ export class AbstractSqlDriver extends DatabaseDriver {
25
25
  const connectionType = this.resolveConnectionType({ ctx: options.ctx, connectionType: options.connectionType });
26
26
  const populate = this.autoJoinOneToOneOwner(meta, options.populate, options.fields);
27
27
  const joinedProps = this.joinedProps(meta, populate, options);
28
- const qb = this.createQueryBuilder(meta.class, options.ctx, connectionType, false, options.logging, undefined, options.em);
28
+ const qb = this.createQueryBuilder(meta.class, options.ctx, connectionType, false, options.logging, undefined, options.em)
29
+ .withSchema(this.getSchemaName(meta, options));
29
30
  const fields = this.buildFields(meta, populate, joinedProps, qb, qb.alias, options);
30
31
  const orderBy = this.buildOrderBy(qb, meta, populate, options);
31
32
  const populateWhere = this.buildPopulateWhere(meta, joinedProps, options);
@@ -44,8 +45,7 @@ export class AbstractSqlDriver extends DatabaseDriver {
44
45
  .having(options.having)
45
46
  .indexHint(options.indexHint)
46
47
  .comment(options.comments)
47
- .hintComment(options.hintComments)
48
- .withSchema(this.getSchemaName(meta, options));
48
+ .hintComment(options.hintComments);
49
49
  if (isCursorPagination) {
50
50
  const { orderBy: newOrderBy, where } = this.processCursorOptions(meta, options, orderBy);
51
51
  qb.andWhere(where).orderBy(newOrderBy);
@@ -172,6 +172,7 @@ export class BasePostgreSqlPlatform extends AbstractSqlPlatform {
172
172
  const quote = (v) => v === '' || v.match(/["{},\\]/) ? JSON.stringify(v) : v;
173
173
  return `{${values.map(v => quote('' + v)).join(',')}}`;
174
174
  }
175
+ /* v8 ignore next */
175
176
  unmarshallArray(value) {
176
177
  if (value === '{}') {
177
178
  return [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mikro-orm/sql",
3
- "version": "7.0.0-dev.115",
3
+ "version": "7.0.0-dev.116",
4
4
  "description": "TypeScript ORM for Node.js based on Data Mapper, Unit of Work and Identity Map patterns. Supports MongoDB, MySQL, PostgreSQL and SQLite databases as well as usage with vanilla JavaScript.",
5
5
  "type": "module",
6
6
  "exports": {
@@ -53,9 +53,9 @@
53
53
  "kysely": "0.28.9"
54
54
  },
55
55
  "devDependencies": {
56
- "@mikro-orm/core": "^6.6.2"
56
+ "@mikro-orm/core": "^6.6.3"
57
57
  },
58
58
  "peerDependencies": {
59
- "@mikro-orm/core": "7.0.0-dev.115"
59
+ "@mikro-orm/core": "7.0.0-dev.116"
60
60
  }
61
61
  }
@@ -35,7 +35,7 @@ export class ObjectCriteriaNode extends CriteriaNode {
35
35
  throw new Error('Mixing collection operators with other filters is not allowed.');
36
36
  }
37
37
  const payload = this.payload[key].unwrap();
38
- const qb2 = qb.clone(true);
38
+ const qb2 = qb.clone(true, ['_schema']);
39
39
  const sub = qb2
40
40
  .from(parentMeta.class)
41
41
  .innerJoin(this.key, qb2.getNextAlias(this.prop.targetMeta.class))
@@ -314,7 +314,7 @@ export declare class QueryBuilder<Entity extends object = AnyEntity, RootAlias e
314
314
  * You can provide the target entity name as the first parameter and use the second parameter to point to an existing property to infer its field name.
315
315
  */
316
316
  as<T>(targetEntity: EntityName<T>, alias: EntityKey<T>): NativeQueryBuilder;
317
- clone(reset?: boolean | string[]): QueryBuilder<Entity>;
317
+ clone(reset?: boolean | string[], preserve?: string[]): QueryBuilder<Entity>;
318
318
  /**
319
319
  * Sets logger context for this query builder.
320
320
  */
@@ -874,11 +874,8 @@ export class QueryBuilder {
874
874
  Object.defineProperty(qb, '__as', { enumerable: false, value: finalAlias });
875
875
  return qb;
876
876
  }
877
- clone(reset) {
877
+ clone(reset, preserve) {
878
878
  const qb = new QueryBuilder(this.mainAlias.entityName, this.metadata, this.driver, this.context, this.mainAlias.aliasName, this.connectionType, this.em);
879
- if (reset === true) {
880
- return qb;
881
- }
882
879
  reset = reset || [];
883
880
  // clone array/object properties
884
881
  const properties = [
@@ -887,13 +884,13 @@ export class QueryBuilder {
887
884
  '_comments', '_hintComments', 'aliasCounter',
888
885
  ];
889
886
  for (const prop of Object.keys(this)) {
890
- if (reset.includes(prop) || ['_helper', '_query'].includes(prop)) {
887
+ if (!preserve?.includes(prop) && (reset === true || reset.includes(prop) || ['_helper', '_query'].includes(prop))) {
891
888
  continue;
892
889
  }
893
890
  qb[prop] = properties.includes(prop) ? Utils.copy(this[prop]) : this[prop];
894
891
  }
895
892
  /* v8 ignore next */
896
- if (this._fields && !reset.includes('_fields')) {
893
+ if (this._fields && reset !== true && !reset.includes('_fields')) {
897
894
  qb._fields = [...this._fields];
898
895
  }
899
896
  qb._aliases = { ...this._aliases };