@mikro-orm/sql 7.0.3 → 7.0.4-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 -410
- package/AbstractSqlDriver.js +1941 -2064
- package/AbstractSqlPlatform.d.ts +73 -83
- package/AbstractSqlPlatform.js +158 -162
- package/PivotCollectionPersister.d.ts +15 -33
- package/PivotCollectionPersister.js +160 -158
- package/README.md +1 -1
- 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 +705 -733
- 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 +3 -3
- 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 +2164 -2294
- 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 -70
- package/schema/SchemaComparator.js +740 -766
- 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
package/AbstractSqlDriver.d.ts
CHANGED
|
@@ -1,43 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
type AnyEntity,
|
|
3
|
-
type Collection,
|
|
4
|
-
type Configuration,
|
|
5
|
-
type ConnectionType,
|
|
6
|
-
type Constructor,
|
|
7
|
-
type CountOptions,
|
|
8
|
-
DatabaseDriver,
|
|
9
|
-
type DeleteOptions,
|
|
10
|
-
type Dictionary,
|
|
11
|
-
type DriverMethodOptions,
|
|
12
|
-
type EntityData,
|
|
13
|
-
type EntityDictionary,
|
|
14
|
-
type EntityField,
|
|
15
|
-
EntityManagerType,
|
|
16
|
-
type EntityMetadata,
|
|
17
|
-
type EntityName,
|
|
18
|
-
type EntityProperty,
|
|
19
|
-
type FilterQuery,
|
|
20
|
-
type FindOneOptions,
|
|
21
|
-
type FindOptions,
|
|
22
|
-
type FormulaTable,
|
|
23
|
-
type LockOptions,
|
|
24
|
-
type LoggingOptions,
|
|
25
|
-
type NativeInsertUpdateManyOptions,
|
|
26
|
-
type NativeInsertUpdateOptions,
|
|
27
|
-
type ObjectQuery,
|
|
28
|
-
type Options,
|
|
29
|
-
type OrderDefinition,
|
|
30
|
-
type PopulateOptions,
|
|
31
|
-
type Primary,
|
|
32
|
-
type QueryOrderMap,
|
|
33
|
-
type QueryResult,
|
|
34
|
-
type Raw,
|
|
35
|
-
RawQueryFragment,
|
|
36
|
-
type StreamOptions,
|
|
37
|
-
type Transaction,
|
|
38
|
-
type UpsertManyOptions,
|
|
39
|
-
type UpsertOptions,
|
|
40
|
-
} from '@mikro-orm/core';
|
|
1
|
+
import { type AnyEntity, type Collection, type Configuration, type ConnectionType, type Constructor, type CountOptions, DatabaseDriver, type DeleteOptions, type Dictionary, type DriverMethodOptions, type EntityData, type EntityDictionary, type EntityField, EntityManagerType, type EntityMetadata, type EntityName, type EntityProperty, type FilterQuery, type FindOneOptions, type FindOptions, type FormulaTable, type LockOptions, type LoggingOptions, type NativeInsertUpdateManyOptions, type NativeInsertUpdateOptions, type ObjectQuery, type Options, type OrderDefinition, type PopulateOptions, type Primary, type QueryOrderMap, type QueryResult, type Raw, RawQueryFragment, type StreamOptions, type Transaction, type UpsertManyOptions, type UpsertOptions } from '@mikro-orm/core';
|
|
41
2
|
import type { AbstractSqlConnection } from './AbstractSqlConnection.js';
|
|
42
3
|
import type { AbstractSqlPlatform } from './AbstractSqlPlatform.js';
|
|
43
4
|
import { type AnyQueryBuilder } from './query/QueryBuilder.js';
|
|
@@ -46,377 +7,161 @@ import { QueryType } from './query/enums.js';
|
|
|
46
7
|
import { SqlEntityManager } from './SqlEntityManager.js';
|
|
47
8
|
import type { InternalField } from './typings.js';
|
|
48
9
|
/** Base class for SQL database drivers, implementing find/insert/update/delete using QueryBuilder. */
|
|
49
|
-
export declare abstract class AbstractSqlDriver<
|
|
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
|
-
entityName: EntityName<T>,
|
|
96
|
-
where:
|
|
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
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
* Load from a polymorphic M:N pivot table.
|
|
194
|
-
*/
|
|
195
|
-
protected loadFromPolymorphicPivotTable<T extends object, O extends object>(
|
|
196
|
-
prop: EntityProperty,
|
|
197
|
-
owners: Primary<O>[][],
|
|
198
|
-
where?: FilterQuery<any>,
|
|
199
|
-
orderBy?: OrderDefinition<T>,
|
|
200
|
-
ctx?: Transaction,
|
|
201
|
-
options?: FindOptions<T, any, any, any>,
|
|
202
|
-
pivotJoin?: boolean,
|
|
203
|
-
): Promise<Dictionary<T[]>>;
|
|
204
|
-
/**
|
|
205
|
-
* Load from owner side of polymorphic M:N (e.g., Post -> Tags)
|
|
206
|
-
*/
|
|
207
|
-
protected loadPolymorphicPivotOwnerSide<T extends object, O extends object>(
|
|
208
|
-
prop: EntityProperty,
|
|
209
|
-
owners: Primary<O>[][],
|
|
210
|
-
where: FilterQuery<any>,
|
|
211
|
-
orderBy?: OrderDefinition<T>,
|
|
212
|
-
ctx?: Transaction,
|
|
213
|
-
options?: FindOptions<T, any, any, any>,
|
|
214
|
-
pivotJoin?: boolean,
|
|
215
|
-
inverseProp?: EntityProperty,
|
|
216
|
-
): Promise<Dictionary<T[]>>;
|
|
217
|
-
/**
|
|
218
|
-
* Load from inverse side of polymorphic M:N (e.g., Tag -> Posts)
|
|
219
|
-
* Uses single query with join via virtual relation on pivot.
|
|
220
|
-
*/
|
|
221
|
-
protected loadPolymorphicPivotInverseSide<T extends object, O extends object>(
|
|
222
|
-
prop: EntityProperty,
|
|
223
|
-
owners: Primary<O>[][],
|
|
224
|
-
where: FilterQuery<any>,
|
|
225
|
-
orderBy?: OrderDefinition<T>,
|
|
226
|
-
ctx?: Transaction,
|
|
227
|
-
options?: FindOptions<T, any, any, any>,
|
|
228
|
-
): Promise<Dictionary<T[]>>;
|
|
229
|
-
/**
|
|
230
|
-
* Build a map from owner PKs to their related entities from pivot table results.
|
|
231
|
-
*/
|
|
232
|
-
private buildPivotResultMap;
|
|
233
|
-
private wrapPopulateFilter;
|
|
234
|
-
private getPivotOrderBy;
|
|
235
|
-
execute<T extends QueryResult | EntityData<AnyEntity> | EntityData<AnyEntity>[] = EntityData<AnyEntity>[]>(
|
|
236
|
-
query: string | NativeQueryBuilder | RawQueryFragment,
|
|
237
|
-
params?: any[],
|
|
238
|
-
method?: 'all' | 'get' | 'run',
|
|
239
|
-
ctx?: Transaction,
|
|
240
|
-
loggerContext?: LoggingOptions,
|
|
241
|
-
): Promise<T>;
|
|
242
|
-
stream<T extends object>(
|
|
243
|
-
entityName: EntityName<T>,
|
|
244
|
-
where: FilterQuery<T>,
|
|
245
|
-
options: StreamOptions<T, any, any, any>,
|
|
246
|
-
): AsyncIterableIterator<T>;
|
|
247
|
-
/**
|
|
248
|
-
* 1:1 owner side needs to be marked for population so QB auto-joins the owner id
|
|
249
|
-
*/
|
|
250
|
-
protected autoJoinOneToOneOwner<T extends object>(
|
|
251
|
-
meta: EntityMetadata<T>,
|
|
252
|
-
populate: PopulateOptions<T>[],
|
|
253
|
-
fields?: readonly EntityField<T, any>[],
|
|
254
|
-
): PopulateOptions<T>[];
|
|
255
|
-
/**
|
|
256
|
-
* @internal
|
|
257
|
-
*/
|
|
258
|
-
joinedProps<T>(
|
|
259
|
-
meta: EntityMetadata,
|
|
260
|
-
populate: readonly PopulateOptions<T>[],
|
|
261
|
-
options?: {
|
|
262
|
-
strategy?: Options['loadStrategy'];
|
|
263
|
-
},
|
|
264
|
-
): PopulateOptions<T>[];
|
|
265
|
-
/**
|
|
266
|
-
* @internal
|
|
267
|
-
*/
|
|
268
|
-
mergeJoinedResult<T extends object>(
|
|
269
|
-
rawResults: EntityData<T>[],
|
|
270
|
-
meta: EntityMetadata<T>,
|
|
271
|
-
joinedProps: PopulateOptions<T>[],
|
|
272
|
-
): EntityData<T>[];
|
|
273
|
-
protected shouldHaveColumn<T, U>(
|
|
274
|
-
meta: EntityMetadata<T>,
|
|
275
|
-
prop: EntityProperty<U>,
|
|
276
|
-
populate: readonly PopulateOptions<U>[],
|
|
277
|
-
fields?: readonly InternalField<U>[],
|
|
278
|
-
exclude?: readonly InternalField<U>[],
|
|
279
|
-
): boolean;
|
|
280
|
-
protected getFieldsForJoinedLoad<T extends object>(
|
|
281
|
-
qb: AnyQueryBuilder<T>,
|
|
282
|
-
meta: EntityMetadata<T>,
|
|
283
|
-
options: FieldsForJoinedLoadOptions<T>,
|
|
284
|
-
): InternalField<T>[];
|
|
285
|
-
/**
|
|
286
|
-
* Adds LEFT JOINs and fields for TPT polymorphic loading when populating a relation to a TPT base class.
|
|
287
|
-
* @internal
|
|
288
|
-
*/
|
|
289
|
-
protected addTPTPolymorphicJoinsForRelation<T extends object>(
|
|
290
|
-
qb: AnyQueryBuilder<T>,
|
|
291
|
-
meta: EntityMetadata<T>,
|
|
292
|
-
baseAlias: string,
|
|
293
|
-
fields: InternalField<T>[],
|
|
294
|
-
): void;
|
|
295
|
-
/**
|
|
296
|
-
* Find the alias for a TPT child table in the query builder.
|
|
297
|
-
* @internal
|
|
298
|
-
*/
|
|
299
|
-
protected findTPTChildAlias<T extends object>(qb: AnyQueryBuilder<T>, childMeta: EntityMetadata): string | undefined;
|
|
300
|
-
/**
|
|
301
|
-
* Builds a CASE WHEN expression for TPT discriminator.
|
|
302
|
-
* Determines concrete entity type based on which child table has a non-null PK.
|
|
303
|
-
* @internal
|
|
304
|
-
*/
|
|
305
|
-
buildTPTDiscriminatorExpression(
|
|
306
|
-
meta: EntityMetadata,
|
|
307
|
-
descendants: EntityMetadata[],
|
|
308
|
-
aliasMap: Dictionary<string>,
|
|
309
|
-
baseAlias: string,
|
|
310
|
-
): Raw;
|
|
311
|
-
/**
|
|
312
|
-
* Maps TPT child-specific fields during hydration.
|
|
313
|
-
* When a relation points to a TPT base class, the actual entity might be a child class.
|
|
314
|
-
* This method reads the discriminator to determine the concrete type and maps child-specific fields.
|
|
315
|
-
* @internal
|
|
316
|
-
*/
|
|
317
|
-
protected mapTPTChildFields<T extends object>(
|
|
318
|
-
relationPojo: EntityData<T>,
|
|
319
|
-
meta: EntityMetadata<T>,
|
|
320
|
-
relationAlias: string,
|
|
321
|
-
qb: AnyQueryBuilder<T>,
|
|
322
|
-
root: EntityData<T>,
|
|
323
|
-
): void;
|
|
324
|
-
/**
|
|
325
|
-
* @internal
|
|
326
|
-
*/
|
|
327
|
-
mapPropToFieldNames<T extends object>(
|
|
328
|
-
qb: AnyQueryBuilder<T>,
|
|
329
|
-
prop: EntityProperty<T>,
|
|
330
|
-
tableAlias: string,
|
|
331
|
-
meta: EntityMetadata<T>,
|
|
332
|
-
schema?: string,
|
|
333
|
-
explicitFields?: readonly InternalField<T>[],
|
|
334
|
-
): InternalField<T>[];
|
|
335
|
-
/** @internal */
|
|
336
|
-
createQueryBuilder<T extends object>(
|
|
337
|
-
entityName: EntityName<T> | AnyQueryBuilder<T>,
|
|
338
|
-
ctx?: Transaction,
|
|
339
|
-
preferredConnectionType?: ConnectionType,
|
|
340
|
-
convertCustomTypes?: boolean,
|
|
341
|
-
loggerContext?: LoggingOptions,
|
|
342
|
-
alias?: string,
|
|
343
|
-
em?: SqlEntityManager,
|
|
344
|
-
): AnyQueryBuilder<T>;
|
|
345
|
-
protected resolveConnectionType(args: { ctx?: Transaction; connectionType?: ConnectionType }): ConnectionType;
|
|
346
|
-
protected extractManyToMany<T>(meta: EntityMetadata<T>, data: EntityDictionary<T>): EntityData<T>;
|
|
347
|
-
protected processManyToMany<T extends object>(
|
|
348
|
-
meta: EntityMetadata<T>,
|
|
349
|
-
pks: Primary<T>[],
|
|
350
|
-
collections: EntityData<T>,
|
|
351
|
-
clear: boolean,
|
|
352
|
-
options?: DriverMethodOptions,
|
|
353
|
-
): Promise<void>;
|
|
354
|
-
lockPessimistic<T extends object>(entity: T, options: LockOptions): Promise<void>;
|
|
355
|
-
protected buildPopulateWhere<T extends object>(
|
|
356
|
-
meta: EntityMetadata<T>,
|
|
357
|
-
joinedProps: PopulateOptions<T>[],
|
|
358
|
-
options: Pick<FindOptions<any>, 'populateWhere'>,
|
|
359
|
-
): ObjectQuery<T>;
|
|
360
|
-
/**
|
|
361
|
-
* Builds a UNION ALL (or UNION) subquery from `unionWhere` branches and merges it
|
|
362
|
-
* into the main WHERE as `pk IN (branch_1 UNION ALL branch_2 ...)`.
|
|
363
|
-
* Each branch is planned independently by the database, enabling per-table index usage.
|
|
364
|
-
*/
|
|
365
|
-
protected applyUnionWhere<T extends object>(
|
|
366
|
-
meta: EntityMetadata<T>,
|
|
367
|
-
where: ObjectQuery<T>,
|
|
368
|
-
options: FindOptions<T, any, any, any> | CountOptions<T> | NativeInsertUpdateOptions<T> | DeleteOptions<T>,
|
|
369
|
-
forDml?: boolean,
|
|
370
|
-
): Promise<ObjectQuery<T>>;
|
|
371
|
-
protected buildOrderBy<T extends object>(
|
|
372
|
-
qb: AnyQueryBuilder<T>,
|
|
373
|
-
meta: EntityMetadata<T>,
|
|
374
|
-
populate: PopulateOptions<T>[],
|
|
375
|
-
options: Pick<FindOptions<any>, 'strategy' | 'orderBy' | 'populateOrderBy'>,
|
|
376
|
-
): QueryOrderMap<T>[];
|
|
377
|
-
protected buildPopulateOrderBy<T extends object>(
|
|
378
|
-
qb: AnyQueryBuilder<T>,
|
|
379
|
-
meta: EntityMetadata<T>,
|
|
380
|
-
populateOrderBy: QueryOrderMap<T>[],
|
|
381
|
-
parentPath: string,
|
|
382
|
-
explicit: boolean,
|
|
383
|
-
parentAlias?: string,
|
|
384
|
-
): QueryOrderMap<T>[];
|
|
385
|
-
protected buildJoinedPropsOrderBy<T extends object>(
|
|
386
|
-
qb: AnyQueryBuilder<T>,
|
|
387
|
-
meta: EntityMetadata<T>,
|
|
388
|
-
populate: PopulateOptions<T>[],
|
|
389
|
-
options?: Pick<FindOptions<any>, 'strategy' | 'orderBy' | 'populateOrderBy'>,
|
|
390
|
-
parentPath?: string,
|
|
391
|
-
): QueryOrderMap<T>[];
|
|
392
|
-
private buildToManyOrderBy;
|
|
393
|
-
protected normalizeFields<T extends object>(fields: InternalField<T>[], prefix?: string): string[];
|
|
394
|
-
protected processField<T extends object>(
|
|
395
|
-
meta: EntityMetadata<T>,
|
|
396
|
-
prop: EntityProperty<T> | undefined,
|
|
397
|
-
field: string,
|
|
398
|
-
ret: InternalField<T>[],
|
|
399
|
-
): void;
|
|
400
|
-
protected buildFields<T extends object>(
|
|
401
|
-
meta: EntityMetadata<T>,
|
|
402
|
-
populate: PopulateOptions<T>[],
|
|
403
|
-
joinedProps: PopulateOptions<T>[],
|
|
404
|
-
qb: AnyQueryBuilder<T>,
|
|
405
|
-
alias: string,
|
|
406
|
-
options: Pick<FindOptions<T, any, any, any>, 'strategy' | 'fields' | 'exclude'>,
|
|
407
|
-
schema?: string,
|
|
408
|
-
): InternalField<T>[];
|
|
10
|
+
export declare abstract class AbstractSqlDriver<Connection extends AbstractSqlConnection = AbstractSqlConnection, Platform extends AbstractSqlPlatform = AbstractSqlPlatform> extends DatabaseDriver<Connection> {
|
|
11
|
+
[EntityManagerType]: SqlEntityManager<this>;
|
|
12
|
+
protected readonly connection: Connection;
|
|
13
|
+
protected readonly replicas: Connection[];
|
|
14
|
+
protected readonly platform: Platform;
|
|
15
|
+
protected constructor(config: Configuration, platform: Platform, connection: Constructor<Connection>, connector: string[]);
|
|
16
|
+
getPlatform(): Platform;
|
|
17
|
+
/** Evaluates a formula callback, handling both string and Raw return values. */
|
|
18
|
+
evaluateFormula(formula: (...args: any[]) => string | Raw, columns: any, table: FormulaTable): string;
|
|
19
|
+
/** For TPT entities, returns ownProps (columns in this table); otherwise returns all props. */
|
|
20
|
+
private getTableProps;
|
|
21
|
+
/** Creates a FormulaTable object for use in formula callbacks. */
|
|
22
|
+
private createFormulaTable;
|
|
23
|
+
private validateSqlOptions;
|
|
24
|
+
createEntityManager(useContext?: boolean): this[typeof EntityManagerType];
|
|
25
|
+
private createQueryBuilderFromOptions;
|
|
26
|
+
find<T extends object, P extends string = never, F extends string = never, E extends string = never>(entityName: EntityName<T>, where: ObjectQuery<T>, options?: FindOptions<T, P, F, E>): Promise<EntityData<T>[]>;
|
|
27
|
+
findOne<T extends object, P extends string = never, F extends string = never, E extends string = never>(entityName: EntityName<T>, where: ObjectQuery<T>, options?: FindOneOptions<T, P, F, E>): Promise<EntityData<T> | null>;
|
|
28
|
+
protected hasToManyJoins<T extends object>(hint: PopulateOptions<T>, meta: EntityMetadata<T>): boolean;
|
|
29
|
+
findVirtual<T extends object>(entityName: EntityName<T>, where: ObjectQuery<T>, options: FindOptions<T, any, any, any>): Promise<EntityData<T>[]>;
|
|
30
|
+
countVirtual<T extends object>(entityName: EntityName<T>, where: ObjectQuery<T>, options: CountOptions<T, any>): Promise<number>;
|
|
31
|
+
protected findFromVirtual<T extends object>(entityName: EntityName<T>, where: ObjectQuery<T>, options: FindOptions<T, any> | CountOptions<T, any>, type: QueryType): Promise<EntityData<T>[] | number>;
|
|
32
|
+
protected streamFromVirtual<T extends object>(entityName: EntityName<T>, where: FilterQuery<T>, options: StreamOptions<T, any>): AsyncIterableIterator<EntityData<T>>;
|
|
33
|
+
protected wrapVirtualExpressionInSubquery<T extends object>(meta: EntityMetadata<T>, expression: string, where: FilterQuery<T>, options: FindOptions<T, any>, type: QueryType): Promise<T[] | number>;
|
|
34
|
+
protected wrapVirtualExpressionInSubqueryStream<T extends object>(meta: EntityMetadata<T>, expression: string, where: FilterQuery<T>, options: FindOptions<T, any, any, any>, type: QueryType.SELECT): AsyncIterableIterator<T>;
|
|
35
|
+
/**
|
|
36
|
+
* Virtual entities have no PKs, so to-many populate joins can't be deduplicated.
|
|
37
|
+
* Force balanced strategy to load to-many relations via separate queries.
|
|
38
|
+
*/
|
|
39
|
+
private forceBalancedStrategy;
|
|
40
|
+
mapResult<T extends object>(result: EntityData<T>, meta: EntityMetadata<T>, populate?: PopulateOptions<T>[], qb?: AnyQueryBuilder<T>, map?: Dictionary): EntityData<T> | null;
|
|
41
|
+
/**
|
|
42
|
+
* Maps aliased columns from TPT parent tables back to their original field names.
|
|
43
|
+
* TPT parent columns are selected with aliases like `parent_alias__column_name`,
|
|
44
|
+
* and need to be renamed back to `column_name` for the result mapper to work.
|
|
45
|
+
*/
|
|
46
|
+
private mapTPTColumns;
|
|
47
|
+
private mapJoinedProps;
|
|
48
|
+
/**
|
|
49
|
+
* Maps a single property from a joined result row into the relation pojo.
|
|
50
|
+
* Handles polymorphic FKs, composite keys, Date parsing, and embedded objects.
|
|
51
|
+
*/
|
|
52
|
+
private mapJoinedProp;
|
|
53
|
+
count<T extends object>(entityName: EntityName<T>, where: any, options?: CountOptions<T>): Promise<number>;
|
|
54
|
+
nativeInsert<T extends object>(entityName: EntityName<T>, data: EntityDictionary<T>, options?: NativeInsertUpdateOptions<T>): Promise<QueryResult<T>>;
|
|
55
|
+
nativeInsertMany<T extends object>(entityName: EntityName<T>, data: EntityDictionary<T>[], options?: NativeInsertUpdateManyOptions<T>, transform?: (sql: string) => string): Promise<QueryResult<T>>;
|
|
56
|
+
nativeUpdate<T extends object>(entityName: EntityName<T>, where: FilterQuery<T>, data: EntityDictionary<T>, options?: NativeInsertUpdateOptions<T> & UpsertOptions<T>): Promise<QueryResult<T>>;
|
|
57
|
+
nativeUpdateMany<T extends object>(entityName: EntityName<T>, where: FilterQuery<T>[], data: EntityDictionary<T>[], options?: NativeInsertUpdateManyOptions<T> & UpsertManyOptions<T>, transform?: (sql: string, params: any[]) => string): Promise<QueryResult<T>>;
|
|
58
|
+
nativeDelete<T extends object>(entityName: EntityName<T>, where: FilterQuery<T> | string | any, options?: DeleteOptions<T>): Promise<QueryResult<T>>;
|
|
59
|
+
/**
|
|
60
|
+
* Fast comparison for collection snapshots that are represented by PK arrays.
|
|
61
|
+
* Compares scalars via `===` and fallbacks to Utils.equals()` for more complex types like Buffer.
|
|
62
|
+
* Always expects the same length of the arrays, since we only compare PKs of the same entity type.
|
|
63
|
+
*/
|
|
64
|
+
private comparePrimaryKeyArrays;
|
|
65
|
+
syncCollections<T extends object, O extends object>(collections: Iterable<Collection<T, O>>, options?: DriverMethodOptions): Promise<void>;
|
|
66
|
+
loadFromPivotTable<T extends object, O extends object>(prop: EntityProperty, owners: Primary<O>[][], where?: FilterQuery<any>, orderBy?: OrderDefinition<T>, ctx?: Transaction, options?: FindOptions<T, any, any, any>, pivotJoin?: boolean): Promise<Dictionary<T[]>>;
|
|
67
|
+
/**
|
|
68
|
+
* Load from a polymorphic M:N pivot table.
|
|
69
|
+
*/
|
|
70
|
+
protected loadFromPolymorphicPivotTable<T extends object, O extends object>(prop: EntityProperty, owners: Primary<O>[][], where?: FilterQuery<any>, orderBy?: OrderDefinition<T>, ctx?: Transaction, options?: FindOptions<T, any, any, any>, pivotJoin?: boolean): Promise<Dictionary<T[]>>;
|
|
71
|
+
/**
|
|
72
|
+
* Load from owner side of polymorphic M:N (e.g., Post -> Tags)
|
|
73
|
+
*/
|
|
74
|
+
protected loadPolymorphicPivotOwnerSide<T extends object, O extends object>(prop: EntityProperty, owners: Primary<O>[][], where: FilterQuery<any>, orderBy?: OrderDefinition<T>, ctx?: Transaction, options?: FindOptions<T, any, any, any>, pivotJoin?: boolean, inverseProp?: EntityProperty): Promise<Dictionary<T[]>>;
|
|
75
|
+
/**
|
|
76
|
+
* Load from inverse side of polymorphic M:N (e.g., Tag -> Posts)
|
|
77
|
+
* Uses single query with join via virtual relation on pivot.
|
|
78
|
+
*/
|
|
79
|
+
protected loadPolymorphicPivotInverseSide<T extends object, O extends object>(prop: EntityProperty, owners: Primary<O>[][], where: FilterQuery<any>, orderBy?: OrderDefinition<T>, ctx?: Transaction, options?: FindOptions<T, any, any, any>): Promise<Dictionary<T[]>>;
|
|
80
|
+
/**
|
|
81
|
+
* Build a map from owner PKs to their related entities from pivot table results.
|
|
82
|
+
*/
|
|
83
|
+
private buildPivotResultMap;
|
|
84
|
+
private wrapPopulateFilter;
|
|
85
|
+
private getPivotOrderBy;
|
|
86
|
+
execute<T extends QueryResult | EntityData<AnyEntity> | EntityData<AnyEntity>[] = EntityData<AnyEntity>[]>(query: string | NativeQueryBuilder | RawQueryFragment, params?: any[], method?: 'all' | 'get' | 'run', ctx?: Transaction, loggerContext?: LoggingOptions): Promise<T>;
|
|
87
|
+
stream<T extends object>(entityName: EntityName<T>, where: FilterQuery<T>, options: StreamOptions<T, any, any, any>): AsyncIterableIterator<T>;
|
|
88
|
+
/**
|
|
89
|
+
* 1:1 owner side needs to be marked for population so QB auto-joins the owner id
|
|
90
|
+
*/
|
|
91
|
+
protected autoJoinOneToOneOwner<T extends object>(meta: EntityMetadata<T>, populate: PopulateOptions<T>[], fields?: readonly EntityField<T, any>[]): PopulateOptions<T>[];
|
|
92
|
+
/**
|
|
93
|
+
* @internal
|
|
94
|
+
*/
|
|
95
|
+
joinedProps<T>(meta: EntityMetadata, populate: readonly PopulateOptions<T>[], options?: {
|
|
96
|
+
strategy?: Options['loadStrategy'];
|
|
97
|
+
}): PopulateOptions<T>[];
|
|
98
|
+
/**
|
|
99
|
+
* @internal
|
|
100
|
+
*/
|
|
101
|
+
mergeJoinedResult<T extends object>(rawResults: EntityData<T>[], meta: EntityMetadata<T>, joinedProps: PopulateOptions<T>[]): EntityData<T>[];
|
|
102
|
+
protected shouldHaveColumn<T, U>(meta: EntityMetadata<T>, prop: EntityProperty<U>, populate: readonly PopulateOptions<U>[], fields?: readonly InternalField<U>[], exclude?: readonly InternalField<U>[]): boolean;
|
|
103
|
+
protected getFieldsForJoinedLoad<T extends object>(qb: AnyQueryBuilder<T>, meta: EntityMetadata<T>, options: FieldsForJoinedLoadOptions<T>): InternalField<T>[];
|
|
104
|
+
/**
|
|
105
|
+
* Adds LEFT JOINs and fields for TPT polymorphic loading when populating a relation to a TPT base class.
|
|
106
|
+
* @internal
|
|
107
|
+
*/
|
|
108
|
+
protected addTPTPolymorphicJoinsForRelation<T extends object>(qb: AnyQueryBuilder<T>, meta: EntityMetadata<T>, baseAlias: string, fields: InternalField<T>[]): void;
|
|
109
|
+
/**
|
|
110
|
+
* Find the alias for a TPT child table in the query builder.
|
|
111
|
+
* @internal
|
|
112
|
+
*/
|
|
113
|
+
protected findTPTChildAlias<T extends object>(qb: AnyQueryBuilder<T>, childMeta: EntityMetadata): string | undefined;
|
|
114
|
+
/**
|
|
115
|
+
* Builds a CASE WHEN expression for TPT discriminator.
|
|
116
|
+
* Determines concrete entity type based on which child table has a non-null PK.
|
|
117
|
+
* @internal
|
|
118
|
+
*/
|
|
119
|
+
buildTPTDiscriminatorExpression(meta: EntityMetadata, descendants: EntityMetadata[], aliasMap: Dictionary<string>, baseAlias: string): Raw;
|
|
120
|
+
/**
|
|
121
|
+
* Maps TPT child-specific fields during hydration.
|
|
122
|
+
* When a relation points to a TPT base class, the actual entity might be a child class.
|
|
123
|
+
* This method reads the discriminator to determine the concrete type and maps child-specific fields.
|
|
124
|
+
* @internal
|
|
125
|
+
*/
|
|
126
|
+
protected mapTPTChildFields<T extends object>(relationPojo: EntityData<T>, meta: EntityMetadata<T>, relationAlias: string, qb: AnyQueryBuilder<T>, root: EntityData<T>): void;
|
|
127
|
+
/**
|
|
128
|
+
* @internal
|
|
129
|
+
*/
|
|
130
|
+
mapPropToFieldNames<T extends object>(qb: AnyQueryBuilder<T>, prop: EntityProperty<T>, tableAlias: string, meta: EntityMetadata<T>, schema?: string, explicitFields?: readonly InternalField<T>[]): InternalField<T>[];
|
|
131
|
+
/** @internal */
|
|
132
|
+
createQueryBuilder<T extends object>(entityName: EntityName<T> | AnyQueryBuilder<T>, ctx?: Transaction, preferredConnectionType?: ConnectionType, convertCustomTypes?: boolean, loggerContext?: LoggingOptions, alias?: string, em?: SqlEntityManager): AnyQueryBuilder<T>;
|
|
133
|
+
protected resolveConnectionType(args: {
|
|
134
|
+
ctx?: Transaction;
|
|
135
|
+
connectionType?: ConnectionType;
|
|
136
|
+
}): ConnectionType;
|
|
137
|
+
protected extractManyToMany<T>(meta: EntityMetadata<T>, data: EntityDictionary<T>): EntityData<T>;
|
|
138
|
+
protected processManyToMany<T extends object>(meta: EntityMetadata<T>, pks: Primary<T>[], collections: EntityData<T>, clear: boolean, options?: DriverMethodOptions): Promise<void>;
|
|
139
|
+
lockPessimistic<T extends object>(entity: T, options: LockOptions): Promise<void>;
|
|
140
|
+
protected buildPopulateWhere<T extends object>(meta: EntityMetadata<T>, joinedProps: PopulateOptions<T>[], options: Pick<FindOptions<any>, 'populateWhere'>): ObjectQuery<T>;
|
|
141
|
+
/**
|
|
142
|
+
* Builds a UNION ALL (or UNION) subquery from `unionWhere` branches and merges it
|
|
143
|
+
* into the main WHERE as `pk IN (branch_1 UNION ALL branch_2 ...)`.
|
|
144
|
+
* Each branch is planned independently by the database, enabling per-table index usage.
|
|
145
|
+
*/
|
|
146
|
+
protected applyUnionWhere<T extends object>(meta: EntityMetadata<T>, where: ObjectQuery<T>, options: FindOptions<T, any, any, any> | CountOptions<T> | NativeInsertUpdateOptions<T> | DeleteOptions<T>, forDml?: boolean): Promise<ObjectQuery<T>>;
|
|
147
|
+
protected buildOrderBy<T extends object>(qb: AnyQueryBuilder<T>, meta: EntityMetadata<T>, populate: PopulateOptions<T>[], options: Pick<FindOptions<any>, 'strategy' | 'orderBy' | 'populateOrderBy'>): QueryOrderMap<T>[];
|
|
148
|
+
protected buildPopulateOrderBy<T extends object>(qb: AnyQueryBuilder<T>, meta: EntityMetadata<T>, populateOrderBy: QueryOrderMap<T>[], parentPath: string, explicit: boolean, parentAlias?: string): QueryOrderMap<T>[];
|
|
149
|
+
protected buildJoinedPropsOrderBy<T extends object>(qb: AnyQueryBuilder<T>, meta: EntityMetadata<T>, populate: PopulateOptions<T>[], options?: Pick<FindOptions<any>, 'strategy' | 'orderBy' | 'populateOrderBy'>, parentPath?: string): QueryOrderMap<T>[];
|
|
150
|
+
private buildToManyOrderBy;
|
|
151
|
+
protected normalizeFields<T extends object>(fields: InternalField<T>[], prefix?: string): string[];
|
|
152
|
+
protected processField<T extends object>(meta: EntityMetadata<T>, prop: EntityProperty<T> | undefined, field: string, ret: InternalField<T>[]): void;
|
|
153
|
+
protected buildFields<T extends object>(meta: EntityMetadata<T>, populate: PopulateOptions<T>[], joinedProps: PopulateOptions<T>[], qb: AnyQueryBuilder<T>, alias: string, options: Pick<FindOptions<T, any, any, any>, 'strategy' | 'fields' | 'exclude'>, schema?: string): InternalField<T>[];
|
|
409
154
|
}
|
|
410
155
|
interface FieldsForJoinedLoadOptions<T extends object> {
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
156
|
+
explicitFields?: readonly InternalField<T>[];
|
|
157
|
+
exclude?: readonly InternalField<T>[];
|
|
158
|
+
populate?: readonly PopulateOptions<T>[];
|
|
159
|
+
strategy?: Options['loadStrategy'];
|
|
160
|
+
populateWhere?: FindOptions<any>['populateWhere'];
|
|
161
|
+
populateFilter?: FindOptions<any>['populateFilter'];
|
|
162
|
+
parentTableAlias: string;
|
|
163
|
+
parentJoinPath?: string;
|
|
164
|
+
count?: boolean;
|
|
165
|
+
schema?: string;
|
|
421
166
|
}
|
|
422
167
|
export {};
|