@mikro-orm/sql 7.0.2-dev.9 → 7.0.2
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/AbstractSqlConnection.d.ts +95 -47
- package/AbstractSqlConnection.js +240 -232
- package/AbstractSqlDriver.d.ts +412 -155
- package/AbstractSqlDriver.js +2062 -1937
- package/AbstractSqlPlatform.d.ts +84 -73
- package/AbstractSqlPlatform.js +163 -158
- package/PivotCollectionPersister.d.ts +33 -15
- package/PivotCollectionPersister.js +158 -160
- package/README.md +128 -294
- package/SqlEntityManager.d.ts +68 -20
- package/SqlEntityManager.js +54 -37
- package/SqlEntityRepository.d.ts +15 -14
- package/SqlEntityRepository.js +24 -23
- package/dialects/mssql/MsSqlNativeQueryBuilder.d.ts +12 -12
- package/dialects/mssql/MsSqlNativeQueryBuilder.js +192 -194
- package/dialects/mysql/BaseMySqlPlatform.d.ts +64 -45
- package/dialects/mysql/BaseMySqlPlatform.js +134 -131
- package/dialects/mysql/MySqlExceptionConverter.d.ts +6 -6
- package/dialects/mysql/MySqlExceptionConverter.js +91 -77
- package/dialects/mysql/MySqlNativeQueryBuilder.d.ts +3 -3
- package/dialects/mysql/MySqlNativeQueryBuilder.js +66 -69
- package/dialects/mysql/MySqlSchemaHelper.d.ts +39 -39
- package/dialects/mysql/MySqlSchemaHelper.js +327 -319
- package/dialects/oracledb/OracleDialect.d.ts +81 -52
- package/dialects/oracledb/OracleDialect.js +155 -149
- package/dialects/oracledb/OracleNativeQueryBuilder.d.ts +12 -12
- package/dialects/oracledb/OracleNativeQueryBuilder.js +232 -236
- package/dialects/postgresql/BasePostgreSqlPlatform.d.ts +108 -105
- package/dialects/postgresql/BasePostgreSqlPlatform.js +351 -350
- package/dialects/postgresql/FullTextType.d.ts +10 -6
- package/dialects/postgresql/FullTextType.js +51 -51
- package/dialects/postgresql/PostgreSqlExceptionConverter.d.ts +5 -5
- package/dialects/postgresql/PostgreSqlExceptionConverter.js +55 -43
- package/dialects/postgresql/PostgreSqlNativeQueryBuilder.d.ts +1 -1
- package/dialects/postgresql/PostgreSqlNativeQueryBuilder.js +4 -4
- package/dialects/postgresql/PostgreSqlSchemaHelper.d.ts +102 -82
- package/dialects/postgresql/PostgreSqlSchemaHelper.js +711 -683
- package/dialects/sqlite/BaseSqliteConnection.d.ts +3 -5
- package/dialects/sqlite/BaseSqliteConnection.js +21 -19
- package/dialects/sqlite/NodeSqliteDialect.d.ts +1 -1
- package/dialects/sqlite/NodeSqliteDialect.js +23 -23
- package/dialects/sqlite/SqliteDriver.d.ts +1 -1
- package/dialects/sqlite/SqliteDriver.js +3 -3
- package/dialects/sqlite/SqliteExceptionConverter.d.ts +6 -6
- package/dialects/sqlite/SqliteExceptionConverter.js +67 -51
- package/dialects/sqlite/SqliteNativeQueryBuilder.d.ts +2 -2
- package/dialects/sqlite/SqliteNativeQueryBuilder.js +7 -7
- package/dialects/sqlite/SqlitePlatform.d.ts +63 -72
- package/dialects/sqlite/SqlitePlatform.js +139 -139
- package/dialects/sqlite/SqliteSchemaHelper.d.ts +70 -60
- package/dialects/sqlite/SqliteSchemaHelper.js +533 -520
- package/package.json +4 -4
- package/plugin/index.d.ts +44 -35
- package/plugin/index.js +44 -36
- package/plugin/transformer.d.ts +117 -94
- package/plugin/transformer.js +890 -881
- package/query/ArrayCriteriaNode.d.ts +4 -4
- package/query/ArrayCriteriaNode.js +18 -18
- package/query/CriteriaNode.d.ts +35 -25
- package/query/CriteriaNode.js +133 -123
- package/query/CriteriaNodeFactory.d.ts +49 -6
- package/query/CriteriaNodeFactory.js +97 -94
- package/query/NativeQueryBuilder.d.ts +120 -117
- package/query/NativeQueryBuilder.js +484 -480
- package/query/ObjectCriteriaNode.d.ts +12 -12
- package/query/ObjectCriteriaNode.js +298 -282
- package/query/QueryBuilder.d.ts +1546 -904
- package/query/QueryBuilder.js +2270 -2145
- package/query/QueryBuilderHelper.d.ts +153 -72
- package/query/QueryBuilderHelper.js +1079 -1028
- package/query/ScalarCriteriaNode.d.ts +3 -3
- package/query/ScalarCriteriaNode.js +53 -46
- package/query/enums.d.ts +16 -14
- package/query/enums.js +16 -14
- package/query/raw.d.ts +16 -6
- package/query/raw.js +10 -10
- package/schema/DatabaseSchema.d.ts +73 -50
- package/schema/DatabaseSchema.js +331 -307
- package/schema/DatabaseTable.d.ts +96 -73
- package/schema/DatabaseTable.js +1012 -927
- package/schema/SchemaComparator.d.ts +58 -54
- package/schema/SchemaComparator.js +745 -719
- package/schema/SchemaHelper.d.ts +110 -80
- package/schema/SchemaHelper.js +676 -645
- package/schema/SqlSchemaGenerator.d.ts +79 -58
- package/schema/SqlSchemaGenerator.js +536 -501
- package/typings.d.ts +380 -266
|
@@ -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
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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
|
}
|
package/query/CriteriaNode.d.ts
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
type EntityKey,
|
|
3
|
+
type EntityProperty,
|
|
4
|
+
type MetadataStorage,
|
|
5
|
+
type RawQueryFragmentSymbol,
|
|
6
|
+
type EntityName,
|
|
7
|
+
} from '@mikro-orm/core';
|
|
2
8
|
import type { ICriteriaNode, ICriteriaNodeProcessOptions, IQueryBuilder } from '../typings.js';
|
|
3
9
|
/**
|
|
4
10
|
* Helper for working with deeply nested where/orderBy/having criteria. Uses composite pattern to build tree from the payload.
|
|
@@ -6,28 +12,32 @@ import type { ICriteriaNode, ICriteriaNodeProcessOptions, IQueryBuilder } from '
|
|
|
6
12
|
* @internal
|
|
7
13
|
*/
|
|
8
14
|
export declare class CriteriaNode<T extends object> implements ICriteriaNode<T> {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
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): 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;
|
|
33
43
|
}
|
package/query/CriteriaNode.js
CHANGED
|
@@ -1,140 +1,150 @@
|
|
|
1
|
-
import { RawQueryFragment, ReferenceKind, Utils, inspect
|
|
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
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
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}`);
|
|
38
39
|
}
|
|
40
|
+
}
|
|
39
41
|
}
|
|
40
|
-
|
|
41
|
-
|
|
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
|
+
const composite = this.prop?.joinColumns ? this.prop.joinColumns.length > 1 : false;
|
|
58
|
+
const rawField = RawQueryFragment.isKnownFragmentSymbol(this.key);
|
|
59
|
+
const scalar =
|
|
60
|
+
payload === null ||
|
|
61
|
+
Utils.isPrimaryKey(payload) ||
|
|
62
|
+
payload instanceof RegExp ||
|
|
63
|
+
payload instanceof Date ||
|
|
64
|
+
rawField;
|
|
65
|
+
const operator =
|
|
66
|
+
Utils.isPlainObject(payload) && Utils.getObjectQueryKeys(payload).every(k => Utils.isOperator(k, false));
|
|
67
|
+
if (composite) {
|
|
68
|
+
return true;
|
|
42
69
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}
|
|
46
|
-
shouldInline(payload) {
|
|
70
|
+
switch (type) {
|
|
71
|
+
case ReferenceKind.MANY_TO_ONE:
|
|
47
72
|
return false;
|
|
48
|
-
|
|
49
|
-
|
|
73
|
+
case ReferenceKind.ONE_TO_ONE:
|
|
74
|
+
return !this.prop.owner;
|
|
75
|
+
case ReferenceKind.ONE_TO_MANY:
|
|
76
|
+
return scalar || operator;
|
|
77
|
+
case ReferenceKind.MANY_TO_MANY:
|
|
78
|
+
return scalar || operator;
|
|
79
|
+
default:
|
|
50
80
|
return false;
|
|
51
81
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
return true;
|
|
64
|
-
}
|
|
65
|
-
switch (type) {
|
|
66
|
-
case ReferenceKind.MANY_TO_ONE:
|
|
67
|
-
return false;
|
|
68
|
-
case ReferenceKind.ONE_TO_ONE:
|
|
69
|
-
return !this.prop.owner;
|
|
70
|
-
case ReferenceKind.ONE_TO_MANY:
|
|
71
|
-
return scalar || operator;
|
|
72
|
-
case ReferenceKind.MANY_TO_MANY:
|
|
73
|
-
return scalar || operator;
|
|
74
|
-
default:
|
|
75
|
-
return false;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
renameFieldToPK(qb, ownerAlias) {
|
|
79
|
-
const joinAlias = qb.getAliasForJoinPath(this.getPath(), { matchPopulateJoins: true });
|
|
80
|
-
if (!joinAlias &&
|
|
81
|
-
this.parent &&
|
|
82
|
-
[ReferenceKind.MANY_TO_ONE, ReferenceKind.ONE_TO_ONE].includes(this.prop.kind) &&
|
|
83
|
-
this.prop.owner) {
|
|
84
|
-
const alias = qb.getAliasForJoinPath(this.parent.getPath()) ?? ownerAlias ?? qb.alias;
|
|
85
|
-
return Utils.getPrimaryKeyHash(this.prop.joinColumns.map(col => `${alias}.${col}`));
|
|
86
|
-
}
|
|
87
|
-
const alias = joinAlias ?? ownerAlias ?? qb.alias;
|
|
88
|
-
if (this.prop.kind === ReferenceKind.MANY_TO_MANY) {
|
|
89
|
-
return Utils.getPrimaryKeyHash(this.prop.inverseJoinColumns.map(col => `${alias}.${col}`));
|
|
90
|
-
}
|
|
91
|
-
return Utils.getPrimaryKeyHash(this.prop.referencedColumnNames.map(col => `${alias}.${col}`));
|
|
92
|
-
}
|
|
93
|
-
getPath(opts) {
|
|
94
|
-
// use index on parent only if we are processing to-many relation
|
|
95
|
-
const addParentIndex = this.prop && [ReferenceKind.ONE_TO_MANY, ReferenceKind.MANY_TO_MANY].includes(this.prop.kind);
|
|
96
|
-
const parentPath = opts?.parentPath ?? this.parent?.getPath({ addIndex: addParentIndex }) ?? Utils.className(this.entityName);
|
|
97
|
-
const index = opts?.addIndex && this.index != null ? `[${this.index}]` : '';
|
|
98
|
-
// ignore group operators to allow easier mapping (e.g. for orderBy)
|
|
99
|
-
const key = this.key && !RawQueryFragment.isKnownFragmentSymbol(this.key) && !['$and', '$or', '$not'].includes(this.key)
|
|
100
|
-
? '.' + this.key
|
|
101
|
-
: '';
|
|
102
|
-
const ret = parentPath + index + key;
|
|
103
|
-
if (this.isPivotJoin()) {
|
|
104
|
-
// distinguish pivot table join from target entity join
|
|
105
|
-
return this.getPivotPath(ret);
|
|
106
|
-
}
|
|
107
|
-
return ret;
|
|
108
|
-
}
|
|
109
|
-
isPivotJoin() {
|
|
110
|
-
if (!this.key || !this.prop) {
|
|
111
|
-
return false;
|
|
112
|
-
}
|
|
113
|
-
const rawField = RawQueryFragment.isKnownFragmentSymbol(this.key);
|
|
114
|
-
const scalar = this.payload === null ||
|
|
115
|
-
Utils.isPrimaryKey(this.payload) ||
|
|
116
|
-
this.payload instanceof RegExp ||
|
|
117
|
-
this.payload instanceof Date ||
|
|
118
|
-
rawField;
|
|
119
|
-
const operator = Utils.isObject(this.payload) && Utils.getObjectQueryKeys(this.payload).every(k => Utils.isOperator(k, false));
|
|
120
|
-
return this.prop.kind === ReferenceKind.MANY_TO_MANY && (scalar || operator);
|
|
121
|
-
}
|
|
122
|
-
getPivotPath(path) {
|
|
123
|
-
return `${path}[pivot]`;
|
|
82
|
+
}
|
|
83
|
+
renameFieldToPK(qb, ownerAlias) {
|
|
84
|
+
const joinAlias = qb.getAliasForJoinPath(this.getPath(), { matchPopulateJoins: true });
|
|
85
|
+
if (
|
|
86
|
+
!joinAlias &&
|
|
87
|
+
this.parent &&
|
|
88
|
+
[ReferenceKind.MANY_TO_ONE, ReferenceKind.ONE_TO_ONE].includes(this.prop.kind) &&
|
|
89
|
+
this.prop.owner
|
|
90
|
+
) {
|
|
91
|
+
const alias = qb.getAliasForJoinPath(this.parent.getPath()) ?? ownerAlias ?? qb.alias;
|
|
92
|
+
return Utils.getPrimaryKeyHash(this.prop.joinColumns.map(col => `${alias}.${col}`));
|
|
124
93
|
}
|
|
125
|
-
|
|
126
|
-
|
|
94
|
+
const alias = joinAlias ?? ownerAlias ?? qb.alias;
|
|
95
|
+
if (this.prop.kind === ReferenceKind.MANY_TO_MANY) {
|
|
96
|
+
return Utils.getPrimaryKeyHash(this.prop.inverseJoinColumns.map(col => `${alias}.${col}`));
|
|
127
97
|
}
|
|
128
|
-
|
|
129
|
-
|
|
98
|
+
return Utils.getPrimaryKeyHash(this.prop.referencedColumnNames.map(col => `${alias}.${col}`));
|
|
99
|
+
}
|
|
100
|
+
getPath(opts) {
|
|
101
|
+
// use index on parent only if we are processing to-many relation
|
|
102
|
+
const addParentIndex =
|
|
103
|
+
this.prop && [ReferenceKind.ONE_TO_MANY, ReferenceKind.MANY_TO_MANY].includes(this.prop.kind);
|
|
104
|
+
const parentPath =
|
|
105
|
+
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 =
|
|
109
|
+
this.key && !RawQueryFragment.isKnownFragmentSymbol(this.key) && !['$and', '$or', '$not'].includes(this.key)
|
|
110
|
+
? '.' + this.key
|
|
111
|
+
: '';
|
|
112
|
+
const ret = parentPath + index + key;
|
|
113
|
+
if (this.isPivotJoin()) {
|
|
114
|
+
// distinguish pivot table join from target entity join
|
|
115
|
+
return this.getPivotPath(ret);
|
|
130
116
|
}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
.filter(k => this[k] !== undefined)
|
|
137
|
-
.forEach(k => (o[k] = this[k]));
|
|
138
|
-
return `${this.constructor.name} ${inspect(o)}`;
|
|
117
|
+
return ret;
|
|
118
|
+
}
|
|
119
|
+
isPivotJoin() {
|
|
120
|
+
if (!this.key || !this.prop) {
|
|
121
|
+
return false;
|
|
139
122
|
}
|
|
123
|
+
const rawField = RawQueryFragment.isKnownFragmentSymbol(this.key);
|
|
124
|
+
const scalar =
|
|
125
|
+
this.payload === null ||
|
|
126
|
+
Utils.isPrimaryKey(this.payload) ||
|
|
127
|
+
this.payload instanceof RegExp ||
|
|
128
|
+
this.payload instanceof Date ||
|
|
129
|
+
rawField;
|
|
130
|
+
const operator =
|
|
131
|
+
Utils.isObject(this.payload) && Utils.getObjectQueryKeys(this.payload).every(k => Utils.isOperator(k, false));
|
|
132
|
+
return this.prop.kind === ReferenceKind.MANY_TO_MANY && (scalar || operator);
|
|
133
|
+
}
|
|
134
|
+
getPivotPath(path) {
|
|
135
|
+
return `${path}[pivot]`;
|
|
136
|
+
}
|
|
137
|
+
aliased(field, alias) {
|
|
138
|
+
return alias ? `${alias}.${field}` : field;
|
|
139
|
+
}
|
|
140
|
+
isStrict() {
|
|
141
|
+
return this.strict;
|
|
142
|
+
}
|
|
143
|
+
/** @ignore */
|
|
144
|
+
/* v8 ignore next */
|
|
145
|
+
[Symbol.for('nodejs.util.inspect.custom')]() {
|
|
146
|
+
const o = {};
|
|
147
|
+
['entityName', 'key', 'index', 'payload'].filter(k => this[k] !== undefined).forEach(k => (o[k] = this[k]));
|
|
148
|
+
return `${this.constructor.name} ${inspect(o)}`;
|
|
149
|
+
}
|
|
140
150
|
}
|
|
@@ -1,12 +1,55 @@
|
|
|
1
|
-
import {
|
|
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';
|
|
2
9
|
import type { ICriteriaNode } from '../typings.js';
|
|
3
10
|
/**
|
|
4
11
|
* @internal
|
|
5
12
|
*/
|
|
6
13
|
export declare class CriteriaNodeFactory {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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>;
|
|
12
55
|
}
|