@mikro-orm/sql 7.0.14 → 7.0.15-dev.0

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.
Files changed (89) hide show
  1. package/AbstractSqlConnection.d.ts +58 -94
  2. package/AbstractSqlConnection.js +238 -235
  3. package/AbstractSqlDriver.d.ts +155 -410
  4. package/AbstractSqlDriver.js +1972 -2100
  5. package/AbstractSqlPlatform.d.ts +76 -86
  6. package/AbstractSqlPlatform.js +167 -169
  7. package/PivotCollectionPersister.d.ts +15 -33
  8. package/PivotCollectionPersister.js +160 -158
  9. package/README.md +1 -1
  10. package/SqlEntityManager.d.ts +22 -67
  11. package/SqlEntityManager.js +38 -54
  12. package/SqlEntityRepository.d.ts +14 -14
  13. package/SqlEntityRepository.js +23 -23
  14. package/SqlMikroORM.d.ts +8 -49
  15. package/SqlMikroORM.js +8 -8
  16. package/dialects/mssql/MsSqlNativeQueryBuilder.d.ts +12 -12
  17. package/dialects/mssql/MsSqlNativeQueryBuilder.js +201 -199
  18. package/dialects/mysql/BaseMySqlPlatform.d.ts +46 -65
  19. package/dialects/mysql/BaseMySqlPlatform.js +134 -137
  20. package/dialects/mysql/MySqlExceptionConverter.d.ts +6 -6
  21. package/dialects/mysql/MySqlExceptionConverter.js +77 -91
  22. package/dialects/mysql/MySqlNativeQueryBuilder.d.ts +3 -3
  23. package/dialects/mysql/MySqlNativeQueryBuilder.js +69 -66
  24. package/dialects/mysql/MySqlSchemaHelper.d.ts +39 -58
  25. package/dialects/mysql/MySqlSchemaHelper.js +319 -327
  26. package/dialects/oracledb/OracleDialect.d.ts +52 -81
  27. package/dialects/oracledb/OracleDialect.js +149 -155
  28. package/dialects/oracledb/OracleNativeQueryBuilder.d.ts +12 -12
  29. package/dialects/oracledb/OracleNativeQueryBuilder.js +243 -239
  30. package/dialects/postgresql/BasePostgreSqlPlatform.d.ts +107 -110
  31. package/dialects/postgresql/BasePostgreSqlPlatform.js +369 -370
  32. package/dialects/postgresql/FullTextType.d.ts +6 -10
  33. package/dialects/postgresql/FullTextType.js +51 -51
  34. package/dialects/postgresql/PostgreSqlExceptionConverter.d.ts +5 -5
  35. package/dialects/postgresql/PostgreSqlExceptionConverter.js +43 -55
  36. package/dialects/postgresql/PostgreSqlNativeQueryBuilder.d.ts +1 -1
  37. package/dialects/postgresql/PostgreSqlNativeQueryBuilder.js +4 -4
  38. package/dialects/postgresql/PostgreSqlSchemaHelper.d.ts +82 -117
  39. package/dialects/postgresql/PostgreSqlSchemaHelper.js +712 -748
  40. package/dialects/sqlite/BaseSqliteConnection.d.ts +5 -3
  41. package/dialects/sqlite/BaseSqliteConnection.js +19 -21
  42. package/dialects/sqlite/NodeSqliteDialect.d.ts +1 -1
  43. package/dialects/sqlite/NodeSqliteDialect.js +23 -23
  44. package/dialects/sqlite/SqliteDriver.d.ts +1 -1
  45. package/dialects/sqlite/SqliteDriver.js +3 -3
  46. package/dialects/sqlite/SqliteExceptionConverter.d.ts +6 -6
  47. package/dialects/sqlite/SqliteExceptionConverter.js +51 -67
  48. package/dialects/sqlite/SqliteNativeQueryBuilder.d.ts +2 -2
  49. package/dialects/sqlite/SqliteNativeQueryBuilder.js +7 -7
  50. package/dialects/sqlite/SqlitePlatform.d.ts +73 -64
  51. package/dialects/sqlite/SqlitePlatform.js +143 -143
  52. package/dialects/sqlite/SqliteSchemaHelper.d.ts +61 -78
  53. package/dialects/sqlite/SqliteSchemaHelper.js +522 -541
  54. package/package.json +2 -2
  55. package/plugin/index.d.ts +35 -42
  56. package/plugin/index.js +36 -43
  57. package/plugin/transformer.d.ts +94 -117
  58. package/plugin/transformer.js +881 -890
  59. package/query/ArrayCriteriaNode.d.ts +4 -4
  60. package/query/ArrayCriteriaNode.js +18 -18
  61. package/query/CriteriaNode.d.ts +25 -35
  62. package/query/CriteriaNode.js +132 -142
  63. package/query/CriteriaNodeFactory.d.ts +6 -49
  64. package/query/CriteriaNodeFactory.js +94 -97
  65. package/query/NativeQueryBuilder.d.ts +120 -120
  66. package/query/NativeQueryBuilder.js +501 -507
  67. package/query/ObjectCriteriaNode.d.ts +12 -12
  68. package/query/ObjectCriteriaNode.js +282 -298
  69. package/query/QueryBuilder.d.ts +906 -1558
  70. package/query/QueryBuilder.js +2202 -2331
  71. package/query/QueryBuilderHelper.d.ts +72 -153
  72. package/query/QueryBuilderHelper.js +1032 -1084
  73. package/query/ScalarCriteriaNode.d.ts +3 -3
  74. package/query/ScalarCriteriaNode.js +46 -53
  75. package/query/enums.d.ts +14 -14
  76. package/query/enums.js +14 -14
  77. package/query/raw.d.ts +6 -16
  78. package/query/raw.js +10 -10
  79. package/schema/DatabaseSchema.d.ts +50 -74
  80. package/schema/DatabaseSchema.js +331 -359
  81. package/schema/DatabaseTable.d.ts +73 -96
  82. package/schema/DatabaseTable.js +974 -1046
  83. package/schema/SchemaComparator.d.ts +66 -70
  84. package/schema/SchemaComparator.js +765 -790
  85. package/schema/SchemaHelper.d.ts +97 -128
  86. package/schema/SchemaHelper.js +668 -683
  87. package/schema/SqlSchemaGenerator.d.ts +59 -79
  88. package/schema/SqlSchemaGenerator.js +495 -525
  89. package/typings.d.ts +275 -405
@@ -4,8 +4,8 @@ import type { IQueryBuilder, ICriteriaNodeProcessOptions } from '../typings.js';
4
4
  * @internal
5
5
  */
6
6
  export declare class ArrayCriteriaNode<T extends object> extends CriteriaNode<T> {
7
- process(qb: IQueryBuilder<T>, options?: ICriteriaNodeProcessOptions): any;
8
- unwrap(): any;
9
- willAutoJoin(qb: IQueryBuilder<T>, alias?: string, options?: ICriteriaNodeProcessOptions): boolean;
10
- isStrict(): boolean;
7
+ process(qb: IQueryBuilder<T>, options?: ICriteriaNodeProcessOptions): any;
8
+ unwrap(): any;
9
+ willAutoJoin(qb: IQueryBuilder<T>, alias?: string, options?: ICriteriaNodeProcessOptions): boolean;
10
+ isStrict(): boolean;
11
11
  }
@@ -3,22 +3,22 @@ import { CriteriaNode } from './CriteriaNode.js';
3
3
  * @internal
4
4
  */
5
5
  export class ArrayCriteriaNode extends CriteriaNode {
6
- process(qb, options) {
7
- return this.payload.map(node => {
8
- return node.process(qb, options);
9
- });
10
- }
11
- unwrap() {
12
- return this.payload.map(node => {
13
- return node.unwrap();
14
- });
15
- }
16
- willAutoJoin(qb, alias, options) {
17
- return this.payload.some(node => {
18
- return node.willAutoJoin(qb, alias, options);
19
- });
20
- }
21
- isStrict() {
22
- return this.strict || this.payload.some(node => node.isStrict());
23
- }
6
+ process(qb, options) {
7
+ return this.payload.map((node) => {
8
+ return node.process(qb, options);
9
+ });
10
+ }
11
+ unwrap() {
12
+ return this.payload.map((node) => {
13
+ return node.unwrap();
14
+ });
15
+ }
16
+ willAutoJoin(qb, alias, options) {
17
+ return this.payload.some((node) => {
18
+ return node.willAutoJoin(qb, alias, options);
19
+ });
20
+ }
21
+ isStrict() {
22
+ return this.strict || this.payload.some((node) => node.isStrict());
23
+ }
24
24
  }
@@ -1,10 +1,4 @@
1
- import {
2
- type EntityKey,
3
- type EntityProperty,
4
- type MetadataStorage,
5
- type RawQueryFragmentSymbol,
6
- type EntityName,
7
- } from '@mikro-orm/core';
1
+ import { type EntityKey, type EntityProperty, type MetadataStorage, type RawQueryFragmentSymbol, type EntityName } from '@mikro-orm/core';
8
2
  import type { ICriteriaNode, ICriteriaNodeProcessOptions, IQueryBuilder } from '../typings.js';
9
3
  /**
10
4
  * Helper for working with deeply nested where/orderBy/having criteria. Uses composite pattern to build tree from the payload.
@@ -12,32 +6,28 @@ import type { ICriteriaNode, ICriteriaNodeProcessOptions, IQueryBuilder } from '
12
6
  * @internal
13
7
  */
14
8
  export declare class CriteriaNode<T extends object> implements ICriteriaNode<T> {
15
- protected readonly metadata: MetadataStorage;
16
- readonly entityName: EntityName<T>;
17
- readonly parent?: ICriteriaNode<T> | undefined;
18
- readonly key?: (EntityKey<T> | RawQueryFragmentSymbol) | undefined;
19
- readonly validate: boolean;
20
- readonly strict: boolean;
21
- payload: any;
22
- prop?: EntityProperty<T>;
23
- index?: number;
24
- constructor(
25
- metadata: MetadataStorage,
26
- entityName: EntityName<T>,
27
- parent?: ICriteriaNode<T> | undefined,
28
- key?: (EntityKey<T> | RawQueryFragmentSymbol) | undefined,
29
- validate?: boolean,
30
- strict?: boolean,
31
- );
32
- process(qb: IQueryBuilder<T>, options?: ICriteriaNodeProcessOptions): any;
33
- unwrap(): any;
34
- shouldInline(payload: any): boolean;
35
- willAutoJoin(qb: IQueryBuilder<T>, alias?: string, options?: ICriteriaNodeProcessOptions): boolean;
36
- shouldRename(payload: any): boolean;
37
- renameFieldToPK<T>(qb: IQueryBuilder<T>, ownerAlias?: string, options?: ICriteriaNodeProcessOptions): string;
38
- getPath(opts?: { addIndex?: boolean; parentPath?: string }): string;
39
- private isPivotJoin;
40
- getPivotPath(path: string): string;
41
- aliased(field: string, alias?: string): string;
42
- isStrict(): boolean;
9
+ protected readonly metadata: MetadataStorage;
10
+ readonly entityName: EntityName<T>;
11
+ readonly parent?: ICriteriaNode<T> | undefined;
12
+ readonly key?: (EntityKey<T> | RawQueryFragmentSymbol) | undefined;
13
+ readonly validate: boolean;
14
+ readonly strict: boolean;
15
+ payload: any;
16
+ prop?: EntityProperty<T>;
17
+ index?: number;
18
+ constructor(metadata: MetadataStorage, entityName: EntityName<T>, parent?: ICriteriaNode<T> | undefined, key?: (EntityKey<T> | RawQueryFragmentSymbol) | undefined, validate?: boolean, strict?: boolean);
19
+ process(qb: IQueryBuilder<T>, options?: ICriteriaNodeProcessOptions): any;
20
+ unwrap(): any;
21
+ shouldInline(payload: any): boolean;
22
+ willAutoJoin(qb: IQueryBuilder<T>, alias?: string, options?: ICriteriaNodeProcessOptions): boolean;
23
+ shouldRename(payload: any): boolean;
24
+ renameFieldToPK<T>(qb: IQueryBuilder<T>, ownerAlias?: string, options?: ICriteriaNodeProcessOptions): string;
25
+ getPath(opts?: {
26
+ addIndex?: boolean;
27
+ parentPath?: string;
28
+ }): string;
29
+ private isPivotJoin;
30
+ getPivotPath(path: string): string;
31
+ aliased(field: string, alias?: string): string;
32
+ isStrict(): boolean;
43
33
  }
@@ -1,159 +1,149 @@
1
- import { RawQueryFragment, ReferenceKind, Utils, inspect } from '@mikro-orm/core';
1
+ import { RawQueryFragment, ReferenceKind, Utils, inspect, } from '@mikro-orm/core';
2
2
  /**
3
3
  * Helper for working with deeply nested where/orderBy/having criteria. Uses composite pattern to build tree from the payload.
4
4
  * Auto-joins relations and converts payload from { books: { publisher: { name: '...' } } } to { 'publisher_alias.name': '...' }
5
5
  * @internal
6
6
  */
7
7
  export class CriteriaNode {
8
- metadata;
9
- entityName;
10
- parent;
11
- key;
12
- validate;
13
- strict;
14
- payload;
15
- prop;
16
- index;
17
- constructor(metadata, entityName, parent, key, validate = true, strict = false) {
18
- this.metadata = metadata;
19
- this.entityName = entityName;
20
- this.parent = parent;
21
- this.key = key;
22
- this.validate = validate;
23
- this.strict = strict;
24
- const meta = parent && metadata.find(parent.entityName);
25
- if (meta && key && !RawQueryFragment.isKnownFragmentSymbol(key)) {
26
- const pks = Utils.splitPrimaryKeys(key);
27
- if (pks.length > 1) {
28
- return;
29
- }
30
- for (const k of pks) {
31
- this.prop = meta.props.find(
32
- prop =>
33
- prop.name === k || (prop.fieldNames?.length === 1 && prop.fieldNames[0] === k && prop.persist !== false),
34
- );
35
- const isProp = this.prop || meta.props.find(prop => (prop.fieldNames || []).includes(k));
36
- // do not validate if the key is prefixed or type casted (e.g. `k::text`)
37
- if (validate && !isProp && !k.includes('.') && !k.includes('::') && !Utils.isOperator(k)) {
38
- throw new Error(`Trying to query by not existing property ${Utils.className(entityName)}.${k}`);
8
+ metadata;
9
+ entityName;
10
+ parent;
11
+ key;
12
+ validate;
13
+ strict;
14
+ payload;
15
+ prop;
16
+ index;
17
+ constructor(metadata, entityName, parent, key, validate = true, strict = false) {
18
+ this.metadata = metadata;
19
+ this.entityName = entityName;
20
+ this.parent = parent;
21
+ this.key = key;
22
+ this.validate = validate;
23
+ this.strict = strict;
24
+ const meta = parent && metadata.find(parent.entityName);
25
+ if (meta && key && !RawQueryFragment.isKnownFragmentSymbol(key)) {
26
+ const pks = Utils.splitPrimaryKeys(key);
27
+ if (pks.length > 1) {
28
+ return;
29
+ }
30
+ for (const k of pks) {
31
+ this.prop = meta.props.find(prop => prop.name === k || (prop.fieldNames?.length === 1 && prop.fieldNames[0] === k && prop.persist !== false));
32
+ const isProp = this.prop || meta.props.find(prop => (prop.fieldNames || []).includes(k));
33
+ // do not validate if the key is prefixed or type casted (e.g. `k::text`)
34
+ if (validate && !isProp && !k.includes('.') && !k.includes('::') && !Utils.isOperator(k)) {
35
+ throw new Error(`Trying to query by not existing property ${Utils.className(entityName)}.${k}`);
36
+ }
37
+ }
39
38
  }
40
- }
41
39
  }
42
- }
43
- process(qb, options) {
44
- return this.payload;
45
- }
46
- unwrap() {
47
- return this.payload;
48
- }
49
- shouldInline(payload) {
50
- return false;
51
- }
52
- willAutoJoin(qb, alias, options) {
53
- return false;
54
- }
55
- shouldRename(payload) {
56
- const type = this.prop ? this.prop.kind : null;
57
- // Polymorphic relations have a composite column set (discriminator + FK), but we only
58
- // need tuple-renaming when the payload is itself a tuple (entity ref expanded by
59
- // `convertCompositeEntityRefs`) or an array-valued operator like `$in`. Scalar payloads
60
- // such as `null` or `{ $ne: null }` keep single-column semantics against `fieldNames[0]`.
61
- const polymorphicComposite =
62
- !!this.prop?.polymorphic &&
63
- (this.prop.fieldNames?.length ?? 0) > 1 &&
64
- (Array.isArray(payload) || (Utils.isPlainObject(payload) && Object.values(payload).some(v => Array.isArray(v))));
65
- const composite = polymorphicComposite || (this.prop?.joinColumns ? this.prop.joinColumns.length > 1 : false);
66
- const rawField = RawQueryFragment.isKnownFragmentSymbol(this.key);
67
- const scalar =
68
- payload === null ||
69
- Utils.isPrimaryKey(payload) ||
70
- payload instanceof RegExp ||
71
- payload instanceof Date ||
72
- rawField;
73
- const operator =
74
- Utils.isPlainObject(payload) && Utils.getObjectQueryKeys(payload).every(k => Utils.isOperator(k, false));
75
- if (composite) {
76
- return true;
40
+ process(qb, options) {
41
+ return this.payload;
77
42
  }
78
- switch (type) {
79
- case ReferenceKind.MANY_TO_ONE:
43
+ unwrap() {
44
+ return this.payload;
45
+ }
46
+ shouldInline(payload) {
80
47
  return false;
81
- case ReferenceKind.ONE_TO_ONE:
82
- return !this.prop.owner;
83
- case ReferenceKind.ONE_TO_MANY:
84
- return scalar || operator;
85
- case ReferenceKind.MANY_TO_MANY:
86
- return scalar || operator;
87
- default:
48
+ }
49
+ willAutoJoin(qb, alias, options) {
88
50
  return false;
89
51
  }
90
- }
91
- renameFieldToPK(qb, ownerAlias, options) {
92
- const joinAlias = qb.getAliasForJoinPath(this.getPath(), { ...options, matchPopulateJoins: true });
93
- if (
94
- !joinAlias &&
95
- this.parent &&
96
- [ReferenceKind.MANY_TO_ONE, ReferenceKind.ONE_TO_ONE].includes(this.prop.kind) &&
97
- this.prop.owner
98
- ) {
99
- const alias = qb.getAliasForJoinPath(this.parent.getPath()) ?? ownerAlias ?? qb.alias;
100
- const columns = this.prop.polymorphic ? this.prop.fieldNames : this.prop.joinColumns;
101
- return Utils.getPrimaryKeyHash(columns.map(col => `${alias}.${col}`));
52
+ shouldRename(payload) {
53
+ const type = this.prop ? this.prop.kind : null;
54
+ // Polymorphic relations have a composite column set (discriminator + FK), but we only
55
+ // need tuple-renaming when the payload is itself a tuple (entity ref expanded by
56
+ // `convertCompositeEntityRefs`) or an array-valued operator like `$in`. Scalar payloads
57
+ // such as `null` or `{ $ne: null }` keep single-column semantics against `fieldNames[0]`.
58
+ const polymorphicComposite = !!this.prop?.polymorphic &&
59
+ (this.prop.fieldNames?.length ?? 0) > 1 &&
60
+ (Array.isArray(payload) ||
61
+ (Utils.isPlainObject(payload) && Object.values(payload).some(v => Array.isArray(v))));
62
+ const composite = polymorphicComposite || (this.prop?.joinColumns ? this.prop.joinColumns.length > 1 : false);
63
+ const rawField = RawQueryFragment.isKnownFragmentSymbol(this.key);
64
+ const scalar = payload === null ||
65
+ Utils.isPrimaryKey(payload) ||
66
+ payload instanceof RegExp ||
67
+ payload instanceof Date ||
68
+ rawField;
69
+ const operator = Utils.isPlainObject(payload) && Utils.getObjectQueryKeys(payload).every(k => Utils.isOperator(k, false));
70
+ if (composite) {
71
+ return true;
72
+ }
73
+ switch (type) {
74
+ case ReferenceKind.MANY_TO_ONE:
75
+ return false;
76
+ case ReferenceKind.ONE_TO_ONE:
77
+ return !this.prop.owner;
78
+ case ReferenceKind.ONE_TO_MANY:
79
+ return scalar || operator;
80
+ case ReferenceKind.MANY_TO_MANY:
81
+ return scalar || operator;
82
+ default:
83
+ return false;
84
+ }
85
+ }
86
+ renameFieldToPK(qb, ownerAlias, options) {
87
+ const joinAlias = qb.getAliasForJoinPath(this.getPath(), { ...options, matchPopulateJoins: true });
88
+ if (!joinAlias &&
89
+ this.parent &&
90
+ [ReferenceKind.MANY_TO_ONE, ReferenceKind.ONE_TO_ONE].includes(this.prop.kind) &&
91
+ this.prop.owner) {
92
+ const alias = qb.getAliasForJoinPath(this.parent.getPath()) ?? ownerAlias ?? qb.alias;
93
+ const columns = this.prop.polymorphic ? this.prop.fieldNames : this.prop.joinColumns;
94
+ return Utils.getPrimaryKeyHash(columns.map(col => `${alias}.${col}`));
95
+ }
96
+ const alias = joinAlias ?? ownerAlias ?? qb.alias;
97
+ if (this.prop.kind === ReferenceKind.MANY_TO_MANY) {
98
+ return Utils.getPrimaryKeyHash(this.prop.inverseJoinColumns.map(col => `${alias}.${col}`));
99
+ }
100
+ return Utils.getPrimaryKeyHash(this.prop.referencedColumnNames.map(col => `${alias}.${col}`));
101
+ }
102
+ getPath(opts) {
103
+ // use index on parent only if we are processing to-many relation
104
+ const addParentIndex = this.prop && [ReferenceKind.ONE_TO_MANY, ReferenceKind.MANY_TO_MANY].includes(this.prop.kind);
105
+ const parentPath = opts?.parentPath ?? this.parent?.getPath({ addIndex: addParentIndex }) ?? Utils.className(this.entityName);
106
+ const index = opts?.addIndex && this.index != null ? `[${this.index}]` : '';
107
+ // ignore group operators to allow easier mapping (e.g. for orderBy)
108
+ const key = this.key && !RawQueryFragment.isKnownFragmentSymbol(this.key) && !['$and', '$or', '$not'].includes(this.key)
109
+ ? '.' + this.key
110
+ : '';
111
+ const ret = parentPath + index + key;
112
+ if (this.isPivotJoin()) {
113
+ // distinguish pivot table join from target entity join
114
+ return this.getPivotPath(ret);
115
+ }
116
+ return ret;
117
+ }
118
+ isPivotJoin() {
119
+ if (!this.key || !this.prop) {
120
+ return false;
121
+ }
122
+ const rawField = RawQueryFragment.isKnownFragmentSymbol(this.key);
123
+ const scalar = this.payload === null ||
124
+ Utils.isPrimaryKey(this.payload) ||
125
+ this.payload instanceof RegExp ||
126
+ this.payload instanceof Date ||
127
+ rawField;
128
+ const operator = Utils.isObject(this.payload) && Utils.getObjectQueryKeys(this.payload).every(k => Utils.isOperator(k, false));
129
+ return this.prop.kind === ReferenceKind.MANY_TO_MANY && (scalar || operator);
130
+ }
131
+ getPivotPath(path) {
132
+ return `${path}[pivot]`;
102
133
  }
103
- const alias = joinAlias ?? ownerAlias ?? qb.alias;
104
- if (this.prop.kind === ReferenceKind.MANY_TO_MANY) {
105
- return Utils.getPrimaryKeyHash(this.prop.inverseJoinColumns.map(col => `${alias}.${col}`));
134
+ aliased(field, alias) {
135
+ return alias ? `${alias}.${field}` : field;
106
136
  }
107
- return Utils.getPrimaryKeyHash(this.prop.referencedColumnNames.map(col => `${alias}.${col}`));
108
- }
109
- getPath(opts) {
110
- // use index on parent only if we are processing to-many relation
111
- const addParentIndex =
112
- this.prop && [ReferenceKind.ONE_TO_MANY, ReferenceKind.MANY_TO_MANY].includes(this.prop.kind);
113
- const parentPath =
114
- opts?.parentPath ?? this.parent?.getPath({ addIndex: addParentIndex }) ?? Utils.className(this.entityName);
115
- const index = opts?.addIndex && this.index != null ? `[${this.index}]` : '';
116
- // ignore group operators to allow easier mapping (e.g. for orderBy)
117
- const key =
118
- this.key && !RawQueryFragment.isKnownFragmentSymbol(this.key) && !['$and', '$or', '$not'].includes(this.key)
119
- ? '.' + this.key
120
- : '';
121
- const ret = parentPath + index + key;
122
- if (this.isPivotJoin()) {
123
- // distinguish pivot table join from target entity join
124
- return this.getPivotPath(ret);
137
+ isStrict() {
138
+ return this.strict;
125
139
  }
126
- return ret;
127
- }
128
- isPivotJoin() {
129
- if (!this.key || !this.prop) {
130
- return false;
140
+ /** @ignore */
141
+ /* v8 ignore next */
142
+ [Symbol.for('nodejs.util.inspect.custom')]() {
143
+ const o = {};
144
+ ['entityName', 'key', 'index', 'payload']
145
+ .filter(k => this[k] !== undefined)
146
+ .forEach(k => (o[k] = this[k]));
147
+ return `${this.constructor.name} ${inspect(o)}`;
131
148
  }
132
- const rawField = RawQueryFragment.isKnownFragmentSymbol(this.key);
133
- const scalar =
134
- this.payload === null ||
135
- Utils.isPrimaryKey(this.payload) ||
136
- this.payload instanceof RegExp ||
137
- this.payload instanceof Date ||
138
- rawField;
139
- const operator =
140
- Utils.isObject(this.payload) && Utils.getObjectQueryKeys(this.payload).every(k => Utils.isOperator(k, false));
141
- return this.prop.kind === ReferenceKind.MANY_TO_MANY && (scalar || operator);
142
- }
143
- getPivotPath(path) {
144
- return `${path}[pivot]`;
145
- }
146
- aliased(field, alias) {
147
- return alias ? `${alias}.${field}` : field;
148
- }
149
- isStrict() {
150
- return this.strict;
151
- }
152
- /** @ignore */
153
- /* v8 ignore next */
154
- [Symbol.for('nodejs.util.inspect.custom')]() {
155
- const o = {};
156
- ['entityName', 'key', 'index', 'payload'].filter(k => this[k] !== undefined).forEach(k => (o[k] = this[k]));
157
- return `${this.constructor.name} ${inspect(o)}`;
158
- }
159
149
  }
@@ -1,55 +1,12 @@
1
- import {
2
- type Dictionary,
3
- type EntityKey,
4
- type EntityMetadata,
5
- type EntityName,
6
- type MetadataStorage,
7
- type RawQueryFragmentSymbol,
8
- } from '@mikro-orm/core';
1
+ import { type Dictionary, type EntityKey, type EntityMetadata, type EntityName, type MetadataStorage, type RawQueryFragmentSymbol } from '@mikro-orm/core';
9
2
  import type { ICriteriaNode } from '../typings.js';
10
3
  /**
11
4
  * @internal
12
5
  */
13
6
  export declare class CriteriaNodeFactory {
14
- static createNode<T extends object>(
15
- metadata: MetadataStorage,
16
- entityName: EntityName<T>,
17
- payload: any,
18
- parent?: ICriteriaNode<T>,
19
- key?: EntityKey<T> | RawQueryFragmentSymbol,
20
- validate?: boolean,
21
- ): ICriteriaNode<T>;
22
- static createScalarNode<T extends object>(
23
- metadata: MetadataStorage,
24
- entityName: EntityName<T>,
25
- payload: any,
26
- parent?: ICriteriaNode<T>,
27
- key?: EntityKey<T> | RawQueryFragmentSymbol,
28
- validate?: boolean,
29
- ): ICriteriaNode<T>;
30
- static createArrayNode<T extends object>(
31
- metadata: MetadataStorage,
32
- entityName: EntityName<T>,
33
- payload: any[],
34
- parent?: ICriteriaNode<T>,
35
- key?: EntityKey<T>,
36
- validate?: boolean,
37
- ): ICriteriaNode<T>;
38
- static createObjectNode<T extends object>(
39
- metadata: MetadataStorage,
40
- entityName: EntityName<T>,
41
- payload: Dictionary,
42
- parent?: ICriteriaNode<T>,
43
- key?: EntityKey<T>,
44
- validate?: boolean,
45
- ): ICriteriaNode<T>;
46
- static createObjectItemNode<T extends object>(
47
- metadata: MetadataStorage,
48
- entityName: EntityName<T>,
49
- node: ICriteriaNode<T>,
50
- payload: Dictionary,
51
- key: EntityKey<T> | RawQueryFragmentSymbol,
52
- meta?: EntityMetadata<T>,
53
- validate?: boolean,
54
- ): ICriteriaNode<T>;
7
+ static createNode<T extends object>(metadata: MetadataStorage, entityName: EntityName<T>, payload: any, parent?: ICriteriaNode<T>, key?: EntityKey<T> | RawQueryFragmentSymbol, validate?: boolean): ICriteriaNode<T>;
8
+ static createScalarNode<T extends object>(metadata: MetadataStorage, entityName: EntityName<T>, payload: any, parent?: ICriteriaNode<T>, key?: EntityKey<T> | RawQueryFragmentSymbol, validate?: boolean): ICriteriaNode<T>;
9
+ static createArrayNode<T extends object>(metadata: MetadataStorage, entityName: EntityName<T>, payload: any[], parent?: ICriteriaNode<T>, key?: EntityKey<T>, validate?: boolean): ICriteriaNode<T>;
10
+ static createObjectNode<T extends object>(metadata: MetadataStorage, entityName: EntityName<T>, payload: Dictionary, parent?: ICriteriaNode<T>, key?: EntityKey<T>, validate?: boolean): ICriteriaNode<T>;
11
+ static createObjectItemNode<T extends object>(metadata: MetadataStorage, entityName: EntityName<T>, node: ICriteriaNode<T>, payload: Dictionary, key: EntityKey<T> | RawQueryFragmentSymbol, meta?: EntityMetadata<T>, validate?: boolean): ICriteriaNode<T>;
55
12
  }