@mikro-orm/sql 7.0.2 → 7.0.3-dev.1
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 +58 -94
- package/AbstractSqlConnection.js +238 -235
- package/AbstractSqlDriver.d.ts +155 -411
- package/AbstractSqlDriver.js +1937 -2061
- package/AbstractSqlPlatform.d.ts +73 -83
- package/AbstractSqlPlatform.js +158 -162
- package/PivotCollectionPersister.d.ts +15 -33
- package/PivotCollectionPersister.js +160 -158
- package/SqlEntityManager.d.ts +22 -67
- package/SqlEntityManager.js +38 -54
- package/SqlEntityRepository.d.ts +14 -14
- package/SqlEntityRepository.js +23 -23
- package/dialects/mssql/MsSqlNativeQueryBuilder.d.ts +12 -12
- package/dialects/mssql/MsSqlNativeQueryBuilder.js +194 -192
- package/dialects/mysql/BaseMySqlPlatform.d.ts +45 -64
- package/dialects/mysql/BaseMySqlPlatform.js +131 -134
- package/dialects/mysql/MySqlExceptionConverter.d.ts +6 -6
- package/dialects/mysql/MySqlExceptionConverter.js +77 -91
- package/dialects/mysql/MySqlNativeQueryBuilder.d.ts +3 -3
- package/dialects/mysql/MySqlNativeQueryBuilder.js +69 -66
- package/dialects/mysql/MySqlSchemaHelper.d.ts +39 -39
- package/dialects/mysql/MySqlSchemaHelper.js +319 -327
- package/dialects/oracledb/OracleDialect.d.ts +52 -81
- package/dialects/oracledb/OracleDialect.js +149 -155
- package/dialects/oracledb/OracleNativeQueryBuilder.d.ts +12 -12
- package/dialects/oracledb/OracleNativeQueryBuilder.js +236 -232
- package/dialects/postgresql/BasePostgreSqlPlatform.d.ts +105 -108
- package/dialects/postgresql/BasePostgreSqlPlatform.js +350 -351
- package/dialects/postgresql/FullTextType.d.ts +6 -10
- package/dialects/postgresql/FullTextType.js +51 -51
- package/dialects/postgresql/PostgreSqlExceptionConverter.d.ts +5 -5
- package/dialects/postgresql/PostgreSqlExceptionConverter.js +43 -55
- package/dialects/postgresql/PostgreSqlNativeQueryBuilder.d.ts +1 -1
- package/dialects/postgresql/PostgreSqlNativeQueryBuilder.js +4 -4
- package/dialects/postgresql/PostgreSqlSchemaHelper.d.ts +82 -102
- package/dialects/postgresql/PostgreSqlSchemaHelper.js +683 -711
- package/dialects/sqlite/BaseSqliteConnection.d.ts +5 -3
- package/dialects/sqlite/BaseSqliteConnection.js +19 -21
- 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 +51 -67
- package/dialects/sqlite/SqliteNativeQueryBuilder.d.ts +2 -2
- package/dialects/sqlite/SqliteNativeQueryBuilder.js +7 -7
- package/dialects/sqlite/SqlitePlatform.d.ts +72 -63
- package/dialects/sqlite/SqlitePlatform.js +139 -139
- package/dialects/sqlite/SqliteSchemaHelper.d.ts +60 -70
- package/dialects/sqlite/SqliteSchemaHelper.js +520 -533
- package/package.json +2 -2
- package/plugin/index.d.ts +35 -42
- package/plugin/index.js +36 -43
- package/plugin/transformer.d.ts +94 -117
- package/plugin/transformer.js +881 -890
- package/query/ArrayCriteriaNode.d.ts +4 -4
- package/query/ArrayCriteriaNode.js +18 -18
- package/query/CriteriaNode.d.ts +25 -35
- package/query/CriteriaNode.js +123 -133
- package/query/CriteriaNodeFactory.d.ts +6 -49
- package/query/CriteriaNodeFactory.js +94 -97
- package/query/NativeQueryBuilder.d.ts +118 -118
- package/query/NativeQueryBuilder.js +480 -484
- package/query/ObjectCriteriaNode.d.ts +12 -12
- package/query/ObjectCriteriaNode.js +282 -298
- package/query/QueryBuilder.d.ts +904 -1546
- package/query/QueryBuilder.js +2145 -2270
- package/query/QueryBuilderHelper.d.ts +72 -153
- package/query/QueryBuilderHelper.js +1028 -1079
- package/query/ScalarCriteriaNode.d.ts +3 -3
- package/query/ScalarCriteriaNode.js +46 -53
- package/query/enums.d.ts +14 -14
- package/query/enums.js +14 -14
- package/query/raw.d.ts +6 -16
- package/query/raw.js +10 -10
- package/schema/DatabaseSchema.d.ts +50 -73
- package/schema/DatabaseSchema.js +307 -331
- package/schema/DatabaseTable.d.ts +73 -96
- package/schema/DatabaseTable.js +927 -1012
- package/schema/SchemaComparator.d.ts +66 -58
- package/schema/SchemaComparator.js +740 -744
- package/schema/SchemaHelper.d.ts +95 -109
- package/schema/SchemaHelper.js +659 -675
- package/schema/SqlSchemaGenerator.d.ts +58 -78
- package/schema/SqlSchemaGenerator.js +501 -535
- package/typings.d.ts +266 -380
|
@@ -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,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
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
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): 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
|
}
|
package/query/CriteriaNode.js
CHANGED
|
@@ -1,150 +1,140 @@
|
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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;
|
|
40
|
+
process(qb, options) {
|
|
41
|
+
return this.payload;
|
|
69
42
|
}
|
|
70
|
-
|
|
71
|
-
|
|
43
|
+
unwrap() {
|
|
44
|
+
return this.payload;
|
|
45
|
+
}
|
|
46
|
+
shouldInline(payload) {
|
|
72
47
|
return false;
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
case ReferenceKind.ONE_TO_MANY:
|
|
76
|
-
return scalar || operator;
|
|
77
|
-
case ReferenceKind.MANY_TO_MANY:
|
|
78
|
-
return scalar || operator;
|
|
79
|
-
default:
|
|
48
|
+
}
|
|
49
|
+
willAutoJoin(qb, alias, options) {
|
|
80
50
|
return false;
|
|
81
51
|
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
52
|
+
shouldRename(payload) {
|
|
53
|
+
const type = this.prop ? this.prop.kind : null;
|
|
54
|
+
const composite = this.prop?.joinColumns ? this.prop.joinColumns.length > 1 : false;
|
|
55
|
+
const rawField = RawQueryFragment.isKnownFragmentSymbol(this.key);
|
|
56
|
+
const scalar = payload === null ||
|
|
57
|
+
Utils.isPrimaryKey(payload) ||
|
|
58
|
+
payload instanceof RegExp ||
|
|
59
|
+
payload instanceof Date ||
|
|
60
|
+
rawField;
|
|
61
|
+
const operator = Utils.isPlainObject(payload) && Utils.getObjectQueryKeys(payload).every(k => Utils.isOperator(k, false));
|
|
62
|
+
if (composite) {
|
|
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]`;
|
|
93
124
|
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
return Utils.getPrimaryKeyHash(this.prop.inverseJoinColumns.map(col => `${alias}.${col}`));
|
|
125
|
+
aliased(field, alias) {
|
|
126
|
+
return alias ? `${alias}.${field}` : field;
|
|
97
127
|
}
|
|
98
|
-
|
|
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);
|
|
128
|
+
isStrict() {
|
|
129
|
+
return this.strict;
|
|
116
130
|
}
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
131
|
+
/** @ignore */
|
|
132
|
+
/* v8 ignore next */
|
|
133
|
+
[Symbol.for('nodejs.util.inspect.custom')]() {
|
|
134
|
+
const o = {};
|
|
135
|
+
['entityName', 'key', 'index', 'payload']
|
|
136
|
+
.filter(k => this[k] !== undefined)
|
|
137
|
+
.forEach(k => (o[k] = this[k]));
|
|
138
|
+
return `${this.constructor.name} ${inspect(o)}`;
|
|
122
139
|
}
|
|
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
|
-
}
|
|
150
140
|
}
|
|
@@ -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
|
-
|
|
15
|
-
metadata: MetadataStorage,
|
|
16
|
-
entityName: EntityName<T>,
|
|
17
|
-
payload:
|
|
18
|
-
|
|
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
|
}
|