@mikro-orm/sql 7.0.0-dev.97 → 7.0.0-dev.99

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (91) hide show
  1. package/AbstractSqlConnection.d.ts +57 -0
  2. package/AbstractSqlConnection.js +239 -0
  3. package/AbstractSqlDriver.d.ts +94 -0
  4. package/AbstractSqlDriver.js +1387 -0
  5. package/AbstractSqlPlatform.d.ts +38 -0
  6. package/AbstractSqlPlatform.js +104 -0
  7. package/LICENSE +21 -0
  8. package/PivotCollectionPersister.d.ts +22 -0
  9. package/PivotCollectionPersister.js +159 -0
  10. package/README.md +390 -0
  11. package/SqlEntityManager.d.ts +33 -0
  12. package/SqlEntityManager.js +44 -0
  13. package/SqlEntityRepository.d.ts +19 -0
  14. package/SqlEntityRepository.js +26 -0
  15. package/dialects/index.d.ts +4 -0
  16. package/dialects/index.js +4 -0
  17. package/dialects/mssql/MsSqlNativeQueryBuilder.d.ts +14 -0
  18. package/dialects/mssql/MsSqlNativeQueryBuilder.js +200 -0
  19. package/dialects/mssql/index.d.ts +1 -0
  20. package/dialects/mssql/index.js +1 -0
  21. package/dialects/mysql/MySqlExceptionConverter.d.ts +9 -0
  22. package/dialects/mysql/MySqlExceptionConverter.js +80 -0
  23. package/dialects/mysql/MySqlNativeQueryBuilder.d.ts +7 -0
  24. package/dialects/mysql/MySqlNativeQueryBuilder.js +77 -0
  25. package/dialects/mysql/MySqlPlatform.d.ts +45 -0
  26. package/dialects/mysql/MySqlPlatform.js +116 -0
  27. package/dialects/mysql/MySqlSchemaHelper.d.ts +36 -0
  28. package/dialects/mysql/MySqlSchemaHelper.js +269 -0
  29. package/dialects/mysql/index.d.ts +4 -0
  30. package/dialects/mysql/index.js +4 -0
  31. package/dialects/postgresql/PostgreSqlNativeQueryBuilder.d.ts +5 -0
  32. package/dialects/postgresql/PostgreSqlNativeQueryBuilder.js +8 -0
  33. package/dialects/postgresql/PostgreSqlTableCompiler.d.ts +1 -0
  34. package/dialects/postgresql/PostgreSqlTableCompiler.js +1 -0
  35. package/dialects/postgresql/index.d.ts +1 -0
  36. package/dialects/postgresql/index.js +1 -0
  37. package/dialects/sqlite/BaseSqliteConnection.d.ts +6 -0
  38. package/dialects/sqlite/BaseSqliteConnection.js +8 -0
  39. package/dialects/sqlite/BaseSqlitePlatform.d.ts +70 -0
  40. package/dialects/sqlite/BaseSqlitePlatform.js +104 -0
  41. package/dialects/sqlite/SqliteExceptionConverter.d.ts +9 -0
  42. package/dialects/sqlite/SqliteExceptionConverter.js +54 -0
  43. package/dialects/sqlite/SqliteNativeQueryBuilder.d.ts +6 -0
  44. package/dialects/sqlite/SqliteNativeQueryBuilder.js +11 -0
  45. package/dialects/sqlite/SqliteSchemaHelper.d.ts +38 -0
  46. package/dialects/sqlite/SqliteSchemaHelper.js +379 -0
  47. package/dialects/sqlite/index.d.ts +5 -0
  48. package/dialects/sqlite/index.js +5 -0
  49. package/index.d.ts +19 -0
  50. package/index.js +19 -0
  51. package/package.json +3 -3
  52. package/plugin/index.d.ts +53 -0
  53. package/plugin/index.js +42 -0
  54. package/plugin/transformer.d.ts +115 -0
  55. package/plugin/transformer.js +883 -0
  56. package/query/ArrayCriteriaNode.d.ts +11 -0
  57. package/query/ArrayCriteriaNode.js +24 -0
  58. package/query/CriteriaNode.d.ts +29 -0
  59. package/query/CriteriaNode.js +121 -0
  60. package/query/CriteriaNodeFactory.d.ts +12 -0
  61. package/query/CriteriaNodeFactory.js +90 -0
  62. package/query/NativeQueryBuilder.d.ts +108 -0
  63. package/query/NativeQueryBuilder.js +425 -0
  64. package/query/ObjectCriteriaNode.d.ts +19 -0
  65. package/query/ObjectCriteriaNode.js +249 -0
  66. package/query/QueryBuilder.d.ts +389 -0
  67. package/query/QueryBuilder.js +1558 -0
  68. package/query/QueryBuilderHelper.d.ts +73 -0
  69. package/query/QueryBuilderHelper.js +756 -0
  70. package/query/ScalarCriteriaNode.d.ts +10 -0
  71. package/query/ScalarCriteriaNode.js +49 -0
  72. package/query/enums.d.ts +18 -0
  73. package/query/enums.js +20 -0
  74. package/query/index.d.ts +10 -0
  75. package/query/index.js +10 -0
  76. package/query/raw.d.ts +59 -0
  77. package/query/raw.js +68 -0
  78. package/schema/DatabaseSchema.d.ts +45 -0
  79. package/schema/DatabaseSchema.js +185 -0
  80. package/schema/DatabaseTable.d.ts +68 -0
  81. package/schema/DatabaseTable.js +793 -0
  82. package/schema/SchemaComparator.d.ts +58 -0
  83. package/schema/SchemaComparator.js +577 -0
  84. package/schema/SchemaHelper.d.ts +76 -0
  85. package/schema/SchemaHelper.js +545 -0
  86. package/schema/SqlSchemaGenerator.d.ts +65 -0
  87. package/schema/SqlSchemaGenerator.js +375 -0
  88. package/schema/index.d.ts +5 -0
  89. package/schema/index.js +5 -0
  90. package/typings.d.ts +272 -0
  91. package/typings.js +1 -0
@@ -0,0 +1,57 @@
1
+ import { type ControlledTransaction, type Dialect, Kysely } from 'kysely';
2
+ import { type AnyEntity, Connection, type Dictionary, type EntityData, type IsolationLevel, type LogContext, type LoggingOptions, type QueryResult, RawQueryFragment, type Transaction, type TransactionEventBroadcaster } from '@mikro-orm/core';
3
+ import type { AbstractSqlPlatform } from './AbstractSqlPlatform.js';
4
+ import { NativeQueryBuilder } from './query/NativeQueryBuilder.js';
5
+ export declare abstract class AbstractSqlConnection extends Connection {
6
+ #private;
7
+ protected platform: AbstractSqlPlatform;
8
+ abstract createKyselyDialect(overrides: Dictionary): Dialect;
9
+ connect(options?: {
10
+ skipOnConnect?: boolean;
11
+ }): Promise<void>;
12
+ createKysely(): void;
13
+ /**
14
+ * @inheritDoc
15
+ */
16
+ close(force?: boolean): Promise<void>;
17
+ /**
18
+ * @inheritDoc
19
+ */
20
+ isConnected(): Promise<boolean>;
21
+ /**
22
+ * @inheritDoc
23
+ */
24
+ checkConnection(): Promise<{
25
+ ok: true;
26
+ } | {
27
+ ok: false;
28
+ reason: string;
29
+ error?: Error;
30
+ }>;
31
+ getClient<T = any>(): Kysely<T>;
32
+ transactional<T>(cb: (trx: Transaction<ControlledTransaction<any, any>>) => Promise<T>, options?: {
33
+ isolationLevel?: IsolationLevel;
34
+ readOnly?: boolean;
35
+ ctx?: ControlledTransaction<any>;
36
+ eventBroadcaster?: TransactionEventBroadcaster;
37
+ loggerContext?: LogContext;
38
+ }): Promise<T>;
39
+ begin(options?: {
40
+ isolationLevel?: IsolationLevel;
41
+ readOnly?: boolean;
42
+ ctx?: ControlledTransaction<any, any>;
43
+ eventBroadcaster?: TransactionEventBroadcaster;
44
+ loggerContext?: LogContext;
45
+ }): Promise<ControlledTransaction<any, any>>;
46
+ commit(ctx: ControlledTransaction<any, any>, eventBroadcaster?: TransactionEventBroadcaster, loggerContext?: LogContext): Promise<void>;
47
+ rollback(ctx: ControlledTransaction<any, any>, eventBroadcaster?: TransactionEventBroadcaster, loggerContext?: LogContext): Promise<void>;
48
+ private prepareQuery;
49
+ execute<T extends QueryResult | EntityData<AnyEntity> | EntityData<AnyEntity>[] = EntityData<AnyEntity>[]>(query: string | NativeQueryBuilder | RawQueryFragment, params?: readonly unknown[], method?: 'all' | 'get' | 'run', ctx?: Transaction, loggerContext?: LoggingOptions): Promise<T>;
50
+ stream<T extends EntityData<AnyEntity>>(query: string | NativeQueryBuilder | RawQueryFragment, params?: readonly unknown[], ctx?: Transaction<Kysely<any>>, loggerContext?: LoggingOptions): AsyncIterableIterator<T>;
51
+ /**
52
+ * Execute raw SQL queries from file
53
+ */
54
+ loadFile(path: string): Promise<void>;
55
+ private getSql;
56
+ protected transformRawResult<T>(res: any, method?: 'all' | 'get' | 'run'): T;
57
+ }
@@ -0,0 +1,239 @@
1
+ import { CompiledQuery, Kysely } from 'kysely';
2
+ import { Connection, EventType, RawQueryFragment, Utils, } from '@mikro-orm/core';
3
+ import { NativeQueryBuilder } from './query/NativeQueryBuilder.js';
4
+ export class AbstractSqlConnection extends Connection {
5
+ #client;
6
+ async connect(options) {
7
+ this.getClient();
8
+ this.connected = true;
9
+ if (options?.skipOnConnect !== true) {
10
+ await this.onConnect();
11
+ }
12
+ }
13
+ createKysely() {
14
+ let driverOptions = this.options.driverOptions ?? this.config.get('driverOptions');
15
+ if (typeof driverOptions === 'function') {
16
+ driverOptions = driverOptions();
17
+ }
18
+ if (driverOptions instanceof Kysely) {
19
+ this.logger.log('info', 'Reusing Kysely client provided via `driverOptions`');
20
+ this.#client = driverOptions;
21
+ }
22
+ else if ('createDriver' in driverOptions) {
23
+ this.logger.log('info', 'Reusing Kysely dialect provided via `driverOptions`');
24
+ this.#client = new Kysely({ dialect: driverOptions });
25
+ }
26
+ else {
27
+ this.#client = new Kysely({
28
+ dialect: this.createKyselyDialect(driverOptions),
29
+ });
30
+ }
31
+ }
32
+ /**
33
+ * @inheritDoc
34
+ */
35
+ async close(force) {
36
+ await super.close(force);
37
+ await this.#client?.destroy();
38
+ this.connected = false;
39
+ this.#client = undefined;
40
+ }
41
+ /**
42
+ * @inheritDoc
43
+ */
44
+ async isConnected() {
45
+ const check = await this.checkConnection();
46
+ return check.ok;
47
+ }
48
+ /**
49
+ * @inheritDoc
50
+ */
51
+ async checkConnection() {
52
+ if (!this.connected) {
53
+ return { ok: false, reason: 'Connection not established' };
54
+ }
55
+ try {
56
+ await this.getClient().executeQuery(CompiledQuery.raw('select 1'));
57
+ return { ok: true };
58
+ }
59
+ catch (error) {
60
+ return { ok: false, reason: error.message, error };
61
+ }
62
+ }
63
+ getClient() {
64
+ if (!this.#client) {
65
+ this.createKysely();
66
+ }
67
+ return this.#client;
68
+ }
69
+ async transactional(cb, options = {}) {
70
+ const trx = await this.begin(options);
71
+ try {
72
+ const ret = await cb(trx);
73
+ await this.commit(trx, options.eventBroadcaster, options.loggerContext);
74
+ return ret;
75
+ }
76
+ catch (error) {
77
+ await this.rollback(trx, options.eventBroadcaster, options.loggerContext);
78
+ throw error;
79
+ }
80
+ }
81
+ async begin(options = {}) {
82
+ if (options.ctx) {
83
+ const ctx = options.ctx;
84
+ await options.eventBroadcaster?.dispatchEvent(EventType.beforeTransactionStart, ctx);
85
+ ctx.index ??= 0;
86
+ const savepointName = `trx${ctx.index + 1}`;
87
+ const trx = await options.ctx.savepoint(savepointName).execute();
88
+ Reflect.defineProperty(trx, 'index', { value: ctx.index + 1 });
89
+ Reflect.defineProperty(trx, 'savepointName', { value: savepointName });
90
+ this.logQuery(this.platform.getSavepointSQL(savepointName), options.loggerContext);
91
+ await options.eventBroadcaster?.dispatchEvent(EventType.afterTransactionStart, trx);
92
+ return trx;
93
+ }
94
+ await this.ensureConnection();
95
+ await options.eventBroadcaster?.dispatchEvent(EventType.beforeTransactionStart);
96
+ let trxBuilder = this.getClient().startTransaction();
97
+ if (options.isolationLevel) {
98
+ trxBuilder = trxBuilder.setIsolationLevel(options.isolationLevel);
99
+ }
100
+ if (options.readOnly) {
101
+ trxBuilder = trxBuilder.setAccessMode('read only');
102
+ }
103
+ const trx = await trxBuilder.execute();
104
+ if (options.ctx) {
105
+ const ctx = options.ctx;
106
+ ctx.index ??= 0;
107
+ const savepointName = `trx${ctx.index + 1}`;
108
+ Reflect.defineProperty(trx, 'index', { value: ctx.index + 1 });
109
+ Reflect.defineProperty(trx, 'savepointName', { value: savepointName });
110
+ this.logQuery(this.platform.getSavepointSQL(savepointName), options.loggerContext);
111
+ }
112
+ else {
113
+ for (const query of this.platform.getBeginTransactionSQL(options)) {
114
+ this.logQuery(query, options.loggerContext);
115
+ }
116
+ }
117
+ await options.eventBroadcaster?.dispatchEvent(EventType.afterTransactionStart, trx);
118
+ return trx;
119
+ }
120
+ async commit(ctx, eventBroadcaster, loggerContext) {
121
+ if (ctx.isRolledBack) {
122
+ return;
123
+ }
124
+ await eventBroadcaster?.dispatchEvent(EventType.beforeTransactionCommit, ctx);
125
+ if ('savepointName' in ctx) {
126
+ await ctx.releaseSavepoint(ctx.savepointName).execute();
127
+ this.logQuery(this.platform.getReleaseSavepointSQL(ctx.savepointName), loggerContext);
128
+ }
129
+ else {
130
+ await ctx.commit().execute();
131
+ this.logQuery(this.platform.getCommitTransactionSQL(), loggerContext);
132
+ }
133
+ await eventBroadcaster?.dispatchEvent(EventType.afterTransactionCommit, ctx);
134
+ }
135
+ async rollback(ctx, eventBroadcaster, loggerContext) {
136
+ await eventBroadcaster?.dispatchEvent(EventType.beforeTransactionRollback, ctx);
137
+ if ('savepointName' in ctx) {
138
+ await ctx.rollbackToSavepoint(ctx.savepointName).execute();
139
+ this.logQuery(this.platform.getRollbackToSavepointSQL(ctx.savepointName), loggerContext);
140
+ }
141
+ else {
142
+ await ctx.rollback().execute();
143
+ this.logQuery(this.platform.getRollbackTransactionSQL(), loggerContext);
144
+ }
145
+ await eventBroadcaster?.dispatchEvent(EventType.afterTransactionRollback, ctx);
146
+ }
147
+ prepareQuery(query, params = []) {
148
+ if (query instanceof NativeQueryBuilder) {
149
+ query = query.toRaw();
150
+ }
151
+ if (query instanceof RawQueryFragment) {
152
+ params = query.params;
153
+ query = query.sql;
154
+ }
155
+ query = this.config.get('onQuery')(query, params);
156
+ const formatted = this.platform.formatQuery(query, params);
157
+ return { query, params, formatted };
158
+ }
159
+ async execute(query, params = [], method = 'all', ctx, loggerContext) {
160
+ await this.ensureConnection();
161
+ const q = this.prepareQuery(query, params);
162
+ const sql = this.getSql(q.query, q.formatted, loggerContext);
163
+ return this.executeQuery(sql, async () => {
164
+ const compiled = CompiledQuery.raw(q.formatted);
165
+ const res = await (ctx ?? this.#client).executeQuery(compiled);
166
+ return this.transformRawResult(res, method);
167
+ }, { ...q, ...loggerContext });
168
+ }
169
+ async *stream(query, params = [], ctx, loggerContext) {
170
+ await this.ensureConnection();
171
+ const q = this.prepareQuery(query, params);
172
+ const sql = this.getSql(q.query, q.formatted, loggerContext);
173
+ // construct the compiled query manually with `kind: 'SelectQueryNode'` to avoid sqlite validation for select queries when streaming
174
+ const compiled = {
175
+ query: {
176
+ kind: 'SelectQueryNode',
177
+ },
178
+ sql: q.formatted,
179
+ parameters: [],
180
+ };
181
+ try {
182
+ const res = (ctx ?? this.getClient()).getExecutor().stream(compiled, 1);
183
+ this.logQuery(sql, {
184
+ sql, params,
185
+ ...loggerContext,
186
+ affected: Utils.isPlainObject(res) ? res.affectedRows : undefined,
187
+ });
188
+ for await (const items of res) {
189
+ for (const row of this.transformRawResult(items, 'all')) {
190
+ yield row;
191
+ }
192
+ }
193
+ }
194
+ catch (e) {
195
+ this.logQuery(sql, { sql, params, ...loggerContext, level: 'error' });
196
+ throw e;
197
+ }
198
+ }
199
+ /**
200
+ * Execute raw SQL queries from file
201
+ */
202
+ async loadFile(path) {
203
+ await this.ensureConnection();
204
+ const { readFile } = globalThis.process.getBuiltinModule('node:fs/promises');
205
+ const buf = await readFile(path);
206
+ try {
207
+ const raw = CompiledQuery.raw(buf.toString());
208
+ await this.getClient().executeQuery(raw);
209
+ }
210
+ catch (e) {
211
+ /* v8 ignore next */
212
+ throw this.platform.getExceptionConverter().convertException(e);
213
+ }
214
+ }
215
+ getSql(query, formatted, context) {
216
+ const logger = this.config.getLogger();
217
+ if (!logger.isEnabled('query', context)) {
218
+ return query;
219
+ }
220
+ if (logger.isEnabled('query-params', context)) {
221
+ return formatted;
222
+ }
223
+ return query;
224
+ }
225
+ transformRawResult(res, method) {
226
+ if (method === 'get') {
227
+ return res.rows[0];
228
+ }
229
+ if (method === 'all') {
230
+ return res.rows;
231
+ }
232
+ return {
233
+ affectedRows: Number(res.numAffectedRows ?? res.rows.length),
234
+ insertId: res.insertId != null ? Number(res.insertId) : res.insertId,
235
+ row: res.rows[0],
236
+ rows: res.rows,
237
+ };
238
+ }
239
+ }
@@ -0,0 +1,94 @@
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 LockOptions, type LoggingOptions, type NativeInsertUpdateManyOptions, type NativeInsertUpdateOptions, type ObjectQuery, type Options, type OrderDefinition, type PopulateOptions, type PopulatePath, type Primary, type QueryOrderMap, type QueryResult, RawQueryFragment, type StreamOptions, type Transaction, type UpsertManyOptions, type UpsertOptions } from '@mikro-orm/core';
2
+ import type { AbstractSqlConnection } from './AbstractSqlConnection.js';
3
+ import type { AbstractSqlPlatform } from './AbstractSqlPlatform.js';
4
+ import { QueryBuilder } from './query/QueryBuilder.js';
5
+ import { type NativeQueryBuilder } from './query/NativeQueryBuilder.js';
6
+ import { QueryType } from './query/enums.js';
7
+ import { SqlEntityManager } from './SqlEntityManager.js';
8
+ import type { Field } from './typings.js';
9
+ export declare abstract class AbstractSqlDriver<Connection extends AbstractSqlConnection = AbstractSqlConnection, Platform extends AbstractSqlPlatform = AbstractSqlPlatform> extends DatabaseDriver<Connection> {
10
+ [EntityManagerType]: SqlEntityManager<this>;
11
+ protected readonly connection: Connection;
12
+ protected readonly replicas: Connection[];
13
+ protected readonly platform: Platform;
14
+ protected constructor(config: Configuration, platform: Platform, connection: Constructor<Connection>, connector: string[]);
15
+ getPlatform(): Platform;
16
+ createEntityManager(useContext?: boolean): this[typeof EntityManagerType];
17
+ private createQueryBuilderFromOptions;
18
+ find<T extends object, P extends string = never, F extends string = PopulatePath.ALL, E extends string = never>(entityName: string, where: ObjectQuery<T>, options?: FindOptions<T, P, F, E>): Promise<EntityData<T>[]>;
19
+ findOne<T extends object, P extends string = never, F extends string = PopulatePath.ALL, E extends string = never>(entityName: string, where: ObjectQuery<T>, options?: FindOneOptions<T, P, F, E>): Promise<EntityData<T> | null>;
20
+ protected hasToManyJoins<T extends object>(hint: PopulateOptions<T>, meta: EntityMetadata<T>): boolean;
21
+ findVirtual<T extends object>(entityName: string, where: ObjectQuery<T>, options: FindOptions<T, any, any, any>): Promise<EntityData<T>[]>;
22
+ countVirtual<T extends object>(entityName: string, where: ObjectQuery<T>, options: CountOptions<T, any>): Promise<number>;
23
+ protected findFromVirtual<T extends object>(entityName: string, where: ObjectQuery<T>, options: FindOptions<T, any> | CountOptions<T, any>, type: QueryType): Promise<EntityData<T>[] | number>;
24
+ protected streamFromVirtual<T extends object>(entityName: EntityName<T>, where: FilterQuery<T>, options: StreamOptions<T, any>): AsyncIterableIterator<EntityData<T>>;
25
+ protected wrapVirtualExpressionInSubquery<T extends object>(meta: EntityMetadata<T>, expression: string, where: FilterQuery<T>, options: FindOptions<T, any>, type: QueryType): Promise<T[] | number>;
26
+ protected wrapVirtualExpressionInSubqueryStream<T extends object>(meta: EntityMetadata<T>, expression: string, where: FilterQuery<T>, options: FindOptions<T, any, any, any>, type: QueryType.SELECT): AsyncIterableIterator<T>;
27
+ mapResult<T extends object>(result: EntityData<T>, meta: EntityMetadata<T>, populate?: PopulateOptions<T>[], qb?: QueryBuilder<T, any, any, any>, map?: Dictionary): EntityData<T> | null;
28
+ private mapJoinedProps;
29
+ count<T extends object>(entityName: string, where: any, options?: CountOptions<T>): Promise<number>;
30
+ nativeInsert<T extends object>(entityName: string, data: EntityDictionary<T>, options?: NativeInsertUpdateOptions<T>): Promise<QueryResult<T>>;
31
+ nativeInsertMany<T extends object>(entityName: string, data: EntityDictionary<T>[], options?: NativeInsertUpdateManyOptions<T>, transform?: (sql: string) => string): Promise<QueryResult<T>>;
32
+ nativeUpdate<T extends object>(entityName: string, where: FilterQuery<T>, data: EntityDictionary<T>, options?: NativeInsertUpdateOptions<T> & UpsertOptions<T>): Promise<QueryResult<T>>;
33
+ nativeUpdateMany<T extends object>(entityName: string, where: FilterQuery<T>[], data: EntityDictionary<T>[], options?: NativeInsertUpdateManyOptions<T> & UpsertManyOptions<T>): Promise<QueryResult<T>>;
34
+ nativeDelete<T extends object>(entityName: string, where: FilterQuery<T> | string | any, options?: DeleteOptions<T>): Promise<QueryResult<T>>;
35
+ /**
36
+ * Fast comparison for collection snapshots that are represented by PK arrays.
37
+ * Compares scalars via `===` and fallbacks to Utils.equals()` for more complex types like Buffer.
38
+ * Always expects the same length of the arrays, since we only compare PKs of the same entity type.
39
+ */
40
+ private comparePrimaryKeyArrays;
41
+ syncCollections<T extends object, O extends object>(collections: Iterable<Collection<T, O>>, options?: DriverMethodOptions): Promise<void>;
42
+ 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[]>>;
43
+ private getPivotOrderBy;
44
+ 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>;
45
+ stream<T extends object>(entityName: EntityName<T>, where: FilterQuery<T>, options: StreamOptions<T, any, any, any>): AsyncIterableIterator<T>;
46
+ /**
47
+ * 1:1 owner side needs to be marked for population so QB auto-joins the owner id
48
+ */
49
+ protected autoJoinOneToOneOwner<T extends object>(meta: EntityMetadata<T>, populate: PopulateOptions<T>[], fields?: readonly EntityField<T, any>[]): PopulateOptions<T>[];
50
+ /**
51
+ * @internal
52
+ */
53
+ joinedProps<T>(meta: EntityMetadata, populate: readonly PopulateOptions<T>[], options?: {
54
+ strategy?: Options['loadStrategy'];
55
+ }): PopulateOptions<T>[];
56
+ /**
57
+ * @internal
58
+ */
59
+ mergeJoinedResult<T extends object>(rawResults: EntityData<T>[], meta: EntityMetadata<T>, joinedProps: PopulateOptions<T>[]): EntityData<T>[];
60
+ protected shouldHaveColumn<T, U>(meta: EntityMetadata<T>, prop: EntityProperty<U>, populate: readonly PopulateOptions<U>[], fields?: readonly Field<U>[], exclude?: readonly Field<U>[]): boolean;
61
+ protected getFieldsForJoinedLoad<T extends object>(qb: QueryBuilder<T, any, any, any>, meta: EntityMetadata<T>, options: FieldsForJoinedLoadOptions<T>): Field<T>[];
62
+ /**
63
+ * @internal
64
+ */
65
+ mapPropToFieldNames<T extends object>(qb: QueryBuilder<T, any, any, any>, prop: EntityProperty<T>, tableAlias: string, explicitFields?: readonly Field<T>[]): Field<T>[];
66
+ /** @internal */
67
+ createQueryBuilder<T extends object>(entityName: EntityName<T> | QueryBuilder<T, any, any, any>, ctx?: Transaction, preferredConnectionType?: ConnectionType, convertCustomTypes?: boolean, loggerContext?: LoggingOptions, alias?: string, em?: SqlEntityManager): QueryBuilder<T, any, any, any>;
68
+ protected resolveConnectionType(args: {
69
+ ctx?: Transaction;
70
+ connectionType?: ConnectionType;
71
+ }): ConnectionType;
72
+ protected extractManyToMany<T>(entityName: string, data: EntityDictionary<T>): EntityData<T>;
73
+ protected processManyToMany<T extends object>(meta: EntityMetadata<T> | undefined, pks: Primary<T>[], collections: EntityData<T>, clear: boolean, options?: DriverMethodOptions): Promise<void>;
74
+ lockPessimistic<T extends object>(entity: T, options: LockOptions): Promise<void>;
75
+ protected buildPopulateWhere<T extends object>(meta: EntityMetadata<T>, joinedProps: PopulateOptions<T>[], options: Pick<FindOptions<any>, 'populateWhere'>): ObjectQuery<T>;
76
+ protected buildOrderBy<T extends object>(qb: QueryBuilder<T, any, any, any>, meta: EntityMetadata<T>, populate: PopulateOptions<T>[], options: Pick<FindOptions<any>, 'strategy' | 'orderBy' | 'populateOrderBy'>): QueryOrderMap<T>[];
77
+ protected buildPopulateOrderBy<T extends object>(qb: QueryBuilder<T, any, any, any>, meta: EntityMetadata<T>, populateOrderBy: QueryOrderMap<T>[], parentPath: string, explicit: boolean, parentAlias?: string): QueryOrderMap<T>[];
78
+ protected buildJoinedPropsOrderBy<T extends object>(qb: QueryBuilder<T, any, any, any>, meta: EntityMetadata<T>, populate: PopulateOptions<T>[], options?: Pick<FindOptions<any>, 'strategy' | 'orderBy' | 'populateOrderBy'>, parentPath?: string): QueryOrderMap<T>[];
79
+ protected normalizeFields<T extends object>(fields: Field<T>[], prefix?: string): string[];
80
+ protected processField<T extends object>(meta: EntityMetadata<T>, prop: EntityProperty<T> | undefined, field: string, ret: Field<T>[]): void;
81
+ protected buildFields<T extends object>(meta: EntityMetadata<T>, populate: PopulateOptions<T>[], joinedProps: PopulateOptions<T>[], qb: QueryBuilder<T, any, any, any>, alias: string, options: Pick<FindOptions<T, any, any, any>, 'strategy' | 'fields' | 'exclude'>): Field<T>[];
82
+ }
83
+ interface FieldsForJoinedLoadOptions<T extends object> {
84
+ explicitFields?: readonly Field<T>[];
85
+ exclude?: readonly Field<T>[];
86
+ populate?: readonly PopulateOptions<T>[];
87
+ strategy?: Options['loadStrategy'];
88
+ populateWhere?: FindOptions<any>['populateWhere'];
89
+ populateFilter?: FindOptions<any>['populateFilter'];
90
+ parentTableAlias: string;
91
+ parentJoinPath?: string;
92
+ count?: boolean;
93
+ }
94
+ export {};