@mikro-orm/sql 7.0.4-dev.8 → 7.0.4
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 +94 -58
- package/AbstractSqlConnection.js +235 -238
- package/AbstractSqlDriver.d.ts +410 -155
- package/AbstractSqlDriver.js +2064 -1941
- package/AbstractSqlPlatform.d.ts +83 -73
- package/AbstractSqlPlatform.js +162 -158
- package/PivotCollectionPersister.d.ts +33 -15
- package/PivotCollectionPersister.js +158 -160
- package/README.md +1 -1
- package/SqlEntityManager.d.ts +67 -22
- package/SqlEntityManager.js +54 -38
- package/SqlEntityRepository.d.ts +14 -14
- package/SqlEntityRepository.js +23 -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 +109 -105
- package/dialects/postgresql/BasePostgreSqlPlatform.js +354 -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 +733 -705
- 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 +3 -3
- package/plugin/index.d.ts +42 -35
- package/plugin/index.js +43 -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 +118 -118
- package/query/NativeQueryBuilder.js +484 -480
- package/query/ObjectCriteriaNode.d.ts +12 -12
- package/query/ObjectCriteriaNode.js +298 -282
- package/query/QueryBuilder.d.ts +1557 -905
- package/query/QueryBuilder.js +2322 -2192
- 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 +14 -14
- package/query/enums.js +14 -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 +70 -66
- package/schema/SchemaComparator.js +766 -740
- package/schema/SchemaHelper.d.ts +109 -95
- package/schema/SchemaHelper.js +675 -659
- package/schema/SqlSchemaGenerator.d.ts +78 -58
- package/schema/SqlSchemaGenerator.js +535 -501
- package/typings.d.ts +380 -266
package/AbstractSqlPlatform.d.ts
CHANGED
|
@@ -1,80 +1,90 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
type RawQueryFragment,
|
|
3
|
+
type Constructor,
|
|
4
|
+
type EntityManager,
|
|
5
|
+
type EntityRepository,
|
|
6
|
+
type IDatabaseDriver,
|
|
7
|
+
type IsolationLevel,
|
|
8
|
+
type MikroORM,
|
|
9
|
+
Platform,
|
|
10
|
+
} from '@mikro-orm/core';
|
|
2
11
|
import { SqlSchemaGenerator } from './schema/SqlSchemaGenerator.js';
|
|
3
12
|
import { type SchemaHelper } from './schema/SchemaHelper.js';
|
|
4
13
|
import type { IndexDef } from './typings.js';
|
|
5
14
|
import { NativeQueryBuilder } from './query/NativeQueryBuilder.js';
|
|
6
15
|
/** Base class for SQL database platforms, providing SQL generation and quoting utilities. */
|
|
7
16
|
export declare abstract class AbstractSqlPlatform extends Platform {
|
|
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
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
}[]
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
17
|
+
#private;
|
|
18
|
+
protected readonly schemaHelper?: SchemaHelper;
|
|
19
|
+
usesPivotTable(): boolean;
|
|
20
|
+
indexForeignKeys(): boolean;
|
|
21
|
+
getRepositoryClass<T extends object>(): Constructor<EntityRepository<T>>;
|
|
22
|
+
getSchemaHelper(): SchemaHelper | undefined;
|
|
23
|
+
/** @inheritDoc */
|
|
24
|
+
lookupExtensions(orm: MikroORM): void;
|
|
25
|
+
getSchemaGenerator(driver: IDatabaseDriver, em?: EntityManager): SqlSchemaGenerator;
|
|
26
|
+
/** @internal */
|
|
27
|
+
createNativeQueryBuilder(): NativeQueryBuilder;
|
|
28
|
+
getBeginTransactionSQL(options?: { isolationLevel?: IsolationLevel; readOnly?: boolean }): string[];
|
|
29
|
+
getCommitTransactionSQL(): string;
|
|
30
|
+
getRollbackTransactionSQL(): string;
|
|
31
|
+
getSavepointSQL(savepointName: string): string;
|
|
32
|
+
getRollbackToSavepointSQL(savepointName: string): string;
|
|
33
|
+
getReleaseSavepointSQL(savepointName: string): string;
|
|
34
|
+
quoteValue(value: any): string;
|
|
35
|
+
getSearchJsonPropertySQL(path: string, type: string, aliased: boolean): string | RawQueryFragment;
|
|
36
|
+
getSearchJsonPropertyKey(path: string[], type: string, aliased: boolean, value?: unknown): string | RawQueryFragment;
|
|
37
|
+
/**
|
|
38
|
+
* Quotes a key for use inside a JSON path expression (e.g. `$.key`).
|
|
39
|
+
* Simple alphanumeric keys are left unquoted; others are wrapped in double quotes.
|
|
40
|
+
* @internal
|
|
41
|
+
*/
|
|
42
|
+
quoteJsonKey(key: string): string;
|
|
43
|
+
getJsonIndexDefinition(index: IndexDef): string[];
|
|
44
|
+
supportsUnionWhere(): boolean;
|
|
45
|
+
supportsSchemas(): boolean;
|
|
46
|
+
/** @inheritDoc */
|
|
47
|
+
generateCustomOrder(escapedColumn: string, values: unknown[]): string;
|
|
48
|
+
/**
|
|
49
|
+
* @internal
|
|
50
|
+
*/
|
|
51
|
+
getOrderByExpression(column: string, direction: string, collation?: string): string[];
|
|
52
|
+
/**
|
|
53
|
+
* Quotes a collation name for use in COLLATE clauses.
|
|
54
|
+
* @internal
|
|
55
|
+
*/
|
|
56
|
+
quoteCollation(collation: string): string;
|
|
57
|
+
/** @internal */
|
|
58
|
+
protected validateCollationName(collation: string): void;
|
|
59
|
+
/** @internal */
|
|
60
|
+
validateJsonPropertyName(name: string): void;
|
|
61
|
+
/**
|
|
62
|
+
* Returns FROM clause for JSON array iteration.
|
|
63
|
+
* @internal
|
|
64
|
+
*/
|
|
65
|
+
getJsonArrayFromSQL(
|
|
66
|
+
column: string,
|
|
67
|
+
alias: string,
|
|
68
|
+
_properties: {
|
|
69
|
+
name: string;
|
|
70
|
+
type: string;
|
|
71
|
+
}[],
|
|
72
|
+
): string;
|
|
73
|
+
/**
|
|
74
|
+
* Returns SQL expression to access an element's property within a JSON array iteration.
|
|
75
|
+
* @internal
|
|
76
|
+
*/
|
|
77
|
+
getJsonArrayElementPropertySQL(alias: string, property: string, _type: string): string;
|
|
78
|
+
/**
|
|
79
|
+
* Wraps JSON array FROM clause and WHERE condition into a full EXISTS condition.
|
|
80
|
+
* MySQL overrides this because `json_table` doesn't support correlated subqueries.
|
|
81
|
+
* @internal
|
|
82
|
+
*/
|
|
83
|
+
getJsonArrayExistsSQL(from: string, where: string): string;
|
|
84
|
+
/**
|
|
85
|
+
* Maps a runtime type name (e.g. 'string', 'number') to a driver-specific bind type constant.
|
|
86
|
+
* Used by NativeQueryBuilder for output bindings.
|
|
87
|
+
* @internal
|
|
88
|
+
*/
|
|
89
|
+
mapToBindType(type: string): unknown;
|
|
80
90
|
}
|
package/AbstractSqlPlatform.js
CHANGED
|
@@ -1,164 +1,168 @@
|
|
|
1
|
-
import { isRaw, JsonProperty, Platform, raw, Utils
|
|
1
|
+
import { isRaw, JsonProperty, Platform, raw, Utils } from '@mikro-orm/core';
|
|
2
2
|
import { SqlEntityRepository } from './SqlEntityRepository.js';
|
|
3
3
|
import { SqlSchemaGenerator } from './schema/SqlSchemaGenerator.js';
|
|
4
4
|
import { NativeQueryBuilder } from './query/NativeQueryBuilder.js';
|
|
5
5
|
/** Base class for SQL database platforms, providing SQL generation and quoting utilities. */
|
|
6
6
|
export class AbstractSqlPlatform extends Platform {
|
|
7
|
-
|
|
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
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
7
|
+
static #JSON_PROPERTY_NAME_RE = /^[a-zA-Z_][a-zA-Z0-9_]*$/;
|
|
8
|
+
schemaHelper;
|
|
9
|
+
usesPivotTable() {
|
|
10
|
+
return true;
|
|
11
|
+
}
|
|
12
|
+
indexForeignKeys() {
|
|
13
|
+
return true;
|
|
14
|
+
}
|
|
15
|
+
getRepositoryClass() {
|
|
16
|
+
return SqlEntityRepository;
|
|
17
|
+
}
|
|
18
|
+
getSchemaHelper() {
|
|
19
|
+
return this.schemaHelper;
|
|
20
|
+
}
|
|
21
|
+
/** @inheritDoc */
|
|
22
|
+
lookupExtensions(orm) {
|
|
23
|
+
SqlSchemaGenerator.register(orm);
|
|
24
|
+
}
|
|
25
|
+
/* v8 ignore next: kept for type inference only */
|
|
26
|
+
getSchemaGenerator(driver, em) {
|
|
27
|
+
return new SqlSchemaGenerator(em ?? driver);
|
|
28
|
+
}
|
|
29
|
+
/** @internal */
|
|
30
|
+
/* v8 ignore next */
|
|
31
|
+
createNativeQueryBuilder() {
|
|
32
|
+
return new NativeQueryBuilder(this);
|
|
33
|
+
}
|
|
34
|
+
getBeginTransactionSQL(options) {
|
|
35
|
+
if (options?.isolationLevel) {
|
|
36
|
+
return [`set transaction isolation level ${options.isolationLevel}`, 'begin'];
|
|
37
|
+
}
|
|
38
|
+
return ['begin'];
|
|
39
|
+
}
|
|
40
|
+
getCommitTransactionSQL() {
|
|
41
|
+
return 'commit';
|
|
42
|
+
}
|
|
43
|
+
getRollbackTransactionSQL() {
|
|
44
|
+
return 'rollback';
|
|
45
|
+
}
|
|
46
|
+
getSavepointSQL(savepointName) {
|
|
47
|
+
return `savepoint ${this.quoteIdentifier(savepointName)}`;
|
|
48
|
+
}
|
|
49
|
+
getRollbackToSavepointSQL(savepointName) {
|
|
50
|
+
return `rollback to savepoint ${this.quoteIdentifier(savepointName)}`;
|
|
51
|
+
}
|
|
52
|
+
getReleaseSavepointSQL(savepointName) {
|
|
53
|
+
return `release savepoint ${this.quoteIdentifier(savepointName)}`;
|
|
54
|
+
}
|
|
55
|
+
quoteValue(value) {
|
|
56
|
+
if (isRaw(value)) {
|
|
57
|
+
return this.formatQuery(value.sql, value.params);
|
|
58
|
+
}
|
|
59
|
+
if (Utils.isPlainObject(value) || value?.[JsonProperty]) {
|
|
60
|
+
return this.escape(JSON.stringify(value));
|
|
61
|
+
}
|
|
62
|
+
return this.escape(value);
|
|
63
|
+
}
|
|
64
|
+
getSearchJsonPropertySQL(path, type, aliased) {
|
|
65
|
+
return this.getSearchJsonPropertyKey(path.split('->'), type, aliased);
|
|
66
|
+
}
|
|
67
|
+
getSearchJsonPropertyKey(path, type, aliased, value) {
|
|
68
|
+
const [a, ...b] = path;
|
|
69
|
+
if (aliased) {
|
|
70
|
+
return raw(
|
|
71
|
+
alias => `json_extract(${this.quoteIdentifier(`${alias}.${a}`)}, '$.${b.map(this.quoteJsonKey).join('.')}')`,
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
return raw(`json_extract(${this.quoteIdentifier(a)}, '$.${b.map(this.quoteJsonKey).join('.')}')`);
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Quotes a key for use inside a JSON path expression (e.g. `$.key`).
|
|
78
|
+
* Simple alphanumeric keys are left unquoted; others are wrapped in double quotes.
|
|
79
|
+
* @internal
|
|
80
|
+
*/
|
|
81
|
+
quoteJsonKey(key) {
|
|
82
|
+
return /^[a-z]\w*$/i.exec(key) ? key : `"${key}"`;
|
|
83
|
+
}
|
|
84
|
+
getJsonIndexDefinition(index) {
|
|
85
|
+
return index.columnNames.map(column => {
|
|
86
|
+
if (!column.includes('.')) {
|
|
87
|
+
return column;
|
|
88
|
+
}
|
|
89
|
+
const [root, ...path] = column.split('.');
|
|
90
|
+
return `(json_extract(${root}, '$.${path.join('.')}'))`;
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
supportsUnionWhere() {
|
|
94
|
+
return true;
|
|
95
|
+
}
|
|
96
|
+
supportsSchemas() {
|
|
97
|
+
return false;
|
|
98
|
+
}
|
|
99
|
+
/** @inheritDoc */
|
|
100
|
+
generateCustomOrder(escapedColumn, values) {
|
|
101
|
+
let ret = '(case ';
|
|
102
|
+
values.forEach((v, i) => {
|
|
103
|
+
ret += `when ${escapedColumn} = ${this.quoteValue(v)} then ${i} `;
|
|
104
|
+
});
|
|
105
|
+
return ret + 'else null end)';
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* @internal
|
|
109
|
+
*/
|
|
110
|
+
getOrderByExpression(column, direction, collation) {
|
|
111
|
+
if (collation) {
|
|
112
|
+
return [`${column} collate ${this.quoteCollation(collation)} ${direction.toLowerCase()}`];
|
|
113
|
+
}
|
|
114
|
+
return [`${column} ${direction.toLowerCase()}`];
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Quotes a collation name for use in COLLATE clauses.
|
|
118
|
+
* @internal
|
|
119
|
+
*/
|
|
120
|
+
quoteCollation(collation) {
|
|
121
|
+
this.validateCollationName(collation);
|
|
122
|
+
return this.quoteIdentifier(collation);
|
|
123
|
+
}
|
|
124
|
+
/** @internal */
|
|
125
|
+
validateCollationName(collation) {
|
|
126
|
+
if (!/^[\w]+$/.test(collation)) {
|
|
127
|
+
throw new Error(`Invalid collation name: '${collation}'. Collation names must contain only word characters.`);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
/** @internal */
|
|
131
|
+
validateJsonPropertyName(name) {
|
|
132
|
+
if (!AbstractSqlPlatform.#JSON_PROPERTY_NAME_RE.test(name)) {
|
|
133
|
+
throw new Error(
|
|
134
|
+
`Invalid JSON property name: '${name}'. JSON property names must contain only alphanumeric characters and underscores.`,
|
|
135
|
+
);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Returns FROM clause for JSON array iteration.
|
|
140
|
+
* @internal
|
|
141
|
+
*/
|
|
142
|
+
getJsonArrayFromSQL(column, alias, _properties) {
|
|
143
|
+
return `json_each(${column}) as ${this.quoteIdentifier(alias)}`;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Returns SQL expression to access an element's property within a JSON array iteration.
|
|
147
|
+
* @internal
|
|
148
|
+
*/
|
|
149
|
+
getJsonArrayElementPropertySQL(alias, property, _type) {
|
|
150
|
+
return `${this.quoteIdentifier(alias)}.${this.quoteIdentifier(property)}`;
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Wraps JSON array FROM clause and WHERE condition into a full EXISTS condition.
|
|
154
|
+
* MySQL overrides this because `json_table` doesn't support correlated subqueries.
|
|
155
|
+
* @internal
|
|
156
|
+
*/
|
|
157
|
+
getJsonArrayExistsSQL(from, where) {
|
|
158
|
+
return `exists (select 1 from ${from} where ${where})`;
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Maps a runtime type name (e.g. 'string', 'number') to a driver-specific bind type constant.
|
|
162
|
+
* Used by NativeQueryBuilder for output bindings.
|
|
163
|
+
* @internal
|
|
164
|
+
*/
|
|
165
|
+
mapToBindType(type) {
|
|
166
|
+
return type;
|
|
167
|
+
}
|
|
164
168
|
}
|
|
@@ -1,18 +1,36 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
type Dictionary,
|
|
3
|
+
type EntityMetadata,
|
|
4
|
+
type EntityProperty,
|
|
5
|
+
type Primary,
|
|
6
|
+
type Transaction,
|
|
7
|
+
} from '@mikro-orm/core';
|
|
2
8
|
import { type AbstractSqlDriver } from './AbstractSqlDriver.js';
|
|
3
9
|
export declare class PivotCollectionPersister<Entity extends object> {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
10
|
+
#private;
|
|
11
|
+
constructor(
|
|
12
|
+
meta: EntityMetadata<Entity>,
|
|
13
|
+
driver: AbstractSqlDriver,
|
|
14
|
+
ctx?: Transaction,
|
|
15
|
+
schema?: string,
|
|
16
|
+
loggerContext?: Dictionary,
|
|
17
|
+
);
|
|
18
|
+
enqueueUpdate(
|
|
19
|
+
prop: EntityProperty<Entity>,
|
|
20
|
+
insertDiff: Primary<Entity>[][],
|
|
21
|
+
deleteDiff: Primary<Entity>[][] | boolean,
|
|
22
|
+
pks: Primary<Entity>[],
|
|
23
|
+
isInitialized?: boolean,
|
|
24
|
+
): void;
|
|
25
|
+
private enqueueInsert;
|
|
26
|
+
private enqueueUpsert;
|
|
27
|
+
private createInsertStatement;
|
|
28
|
+
private enqueueDelete;
|
|
29
|
+
/**
|
|
30
|
+
* Build the keys and data arrays for pivot table operations.
|
|
31
|
+
* Handles polymorphic M:N by prepending the discriminator column/value.
|
|
32
|
+
*/
|
|
33
|
+
private buildPivotKeysAndData;
|
|
34
|
+
private collectStatements;
|
|
35
|
+
execute(): Promise<void>;
|
|
18
36
|
}
|