@mikro-orm/sql 7.0.0-dev.98 → 7.0.0-rc.0
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 +6 -7
- package/AbstractSqlConnection.js +27 -24
- package/AbstractSqlDriver.d.ts +82 -23
- package/AbstractSqlDriver.js +584 -184
- package/AbstractSqlPlatform.d.ts +3 -4
- package/AbstractSqlPlatform.js +0 -4
- package/PivotCollectionPersister.d.ts +5 -0
- package/PivotCollectionPersister.js +30 -12
- package/SqlEntityManager.d.ts +2 -2
- package/dialects/mysql/{MySqlPlatform.d.ts → BaseMySqlPlatform.d.ts} +3 -2
- package/dialects/mysql/{MySqlPlatform.js → BaseMySqlPlatform.js} +5 -1
- package/dialects/mysql/MySqlSchemaHelper.d.ts +12 -1
- package/dialects/mysql/MySqlSchemaHelper.js +97 -6
- package/dialects/mysql/index.d.ts +1 -2
- package/dialects/mysql/index.js +1 -2
- package/dialects/postgresql/BasePostgreSqlPlatform.d.ts +106 -0
- package/dialects/postgresql/BasePostgreSqlPlatform.js +350 -0
- package/dialects/postgresql/FullTextType.d.ts +14 -0
- package/dialects/postgresql/FullTextType.js +59 -0
- package/dialects/postgresql/PostgreSqlExceptionConverter.d.ts +8 -0
- package/dialects/postgresql/PostgreSqlExceptionConverter.js +47 -0
- package/dialects/postgresql/PostgreSqlSchemaHelper.d.ts +90 -0
- package/dialects/postgresql/PostgreSqlSchemaHelper.js +732 -0
- package/dialects/postgresql/index.d.ts +3 -0
- package/dialects/postgresql/index.js +3 -0
- package/dialects/sqlite/BaseSqliteConnection.d.ts +1 -0
- package/dialects/sqlite/BaseSqliteConnection.js +14 -1
- package/dialects/sqlite/BaseSqlitePlatform.d.ts +6 -0
- package/dialects/sqlite/BaseSqlitePlatform.js +12 -0
- package/dialects/sqlite/SqliteSchemaHelper.d.ts +25 -0
- package/dialects/sqlite/SqliteSchemaHelper.js +145 -19
- package/dialects/sqlite/index.d.ts +0 -1
- package/dialects/sqlite/index.js +0 -1
- package/package.json +5 -6
- package/plugin/transformer.d.ts +1 -1
- package/plugin/transformer.js +1 -1
- package/query/CriteriaNode.d.ts +9 -5
- package/query/CriteriaNode.js +16 -15
- package/query/CriteriaNodeFactory.d.ts +6 -6
- package/query/CriteriaNodeFactory.js +33 -31
- package/query/NativeQueryBuilder.d.ts +3 -2
- package/query/NativeQueryBuilder.js +1 -2
- package/query/ObjectCriteriaNode.js +50 -35
- package/query/QueryBuilder.d.ts +548 -79
- package/query/QueryBuilder.js +537 -159
- package/query/QueryBuilderHelper.d.ts +22 -14
- package/query/QueryBuilderHelper.js +158 -69
- package/query/ScalarCriteriaNode.js +2 -2
- package/query/raw.d.ts +11 -3
- package/query/raw.js +1 -2
- package/schema/DatabaseSchema.d.ts +15 -2
- package/schema/DatabaseSchema.js +143 -15
- package/schema/DatabaseTable.d.ts +12 -0
- package/schema/DatabaseTable.js +91 -31
- package/schema/SchemaComparator.d.ts +8 -0
- package/schema/SchemaComparator.js +126 -3
- package/schema/SchemaHelper.d.ts +26 -3
- package/schema/SchemaHelper.js +98 -11
- package/schema/SqlSchemaGenerator.d.ts +10 -0
- package/schema/SqlSchemaGenerator.js +137 -9
- package/tsconfig.build.tsbuildinfo +1 -0
- package/typings.d.ts +74 -36
- package/dialects/postgresql/PostgreSqlTableCompiler.d.ts +0 -1
- package/dialects/postgresql/PostgreSqlTableCompiler.js +0 -1
|
@@ -1,14 +1,15 @@
|
|
|
1
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
|
|
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
3
|
import type { AbstractSqlPlatform } from './AbstractSqlPlatform.js';
|
|
4
4
|
import { NativeQueryBuilder } from './query/NativeQueryBuilder.js';
|
|
5
5
|
export declare abstract class AbstractSqlConnection extends Connection {
|
|
6
|
+
#private;
|
|
6
7
|
protected platform: AbstractSqlPlatform;
|
|
7
|
-
|
|
8
|
-
abstract createKyselyDialect(overrides: Dictionary): MaybePromise<Dialect>;
|
|
8
|
+
abstract createKyselyDialect(overrides: Dictionary): Dialect;
|
|
9
9
|
connect(options?: {
|
|
10
10
|
skipOnConnect?: boolean;
|
|
11
11
|
}): Promise<void>;
|
|
12
|
+
createKysely(): void;
|
|
12
13
|
/**
|
|
13
14
|
* @inheritDoc
|
|
14
15
|
*/
|
|
@@ -47,10 +48,8 @@ export declare abstract class AbstractSqlConnection extends Connection {
|
|
|
47
48
|
private prepareQuery;
|
|
48
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>;
|
|
49
50
|
stream<T extends EntityData<AnyEntity>>(query: string | NativeQueryBuilder | RawQueryFragment, params?: readonly unknown[], ctx?: Transaction<Kysely<any>>, loggerContext?: LoggingOptions): AsyncIterableIterator<T>;
|
|
50
|
-
/**
|
|
51
|
-
|
|
52
|
-
*/
|
|
53
|
-
loadFile(path: string): Promise<void>;
|
|
51
|
+
/** @inheritDoc */
|
|
52
|
+
executeDump(dump: string): Promise<void>;
|
|
54
53
|
private getSql;
|
|
55
54
|
protected transformRawResult<T>(res: any, method?: 'all' | 'get' | 'run'): T;
|
|
56
55
|
}
|
package/AbstractSqlConnection.js
CHANGED
|
@@ -2,37 +2,41 @@ import { CompiledQuery, Kysely } from 'kysely';
|
|
|
2
2
|
import { Connection, EventType, RawQueryFragment, Utils, } from '@mikro-orm/core';
|
|
3
3
|
import { NativeQueryBuilder } from './query/NativeQueryBuilder.js';
|
|
4
4
|
export class AbstractSqlConnection extends Connection {
|
|
5
|
-
client;
|
|
5
|
+
#client;
|
|
6
6
|
async connect(options) {
|
|
7
|
+
this.getClient();
|
|
8
|
+
this.connected = true;
|
|
9
|
+
if (options?.skipOnConnect !== true) {
|
|
10
|
+
await this.onConnect();
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
createKysely() {
|
|
7
14
|
let driverOptions = this.options.driverOptions ?? this.config.get('driverOptions');
|
|
8
15
|
if (typeof driverOptions === 'function') {
|
|
9
|
-
driverOptions =
|
|
16
|
+
driverOptions = driverOptions();
|
|
10
17
|
}
|
|
11
18
|
if (driverOptions instanceof Kysely) {
|
|
12
19
|
this.logger.log('info', 'Reusing Kysely client provided via `driverOptions`');
|
|
13
|
-
this
|
|
20
|
+
this.#client = driverOptions;
|
|
14
21
|
}
|
|
15
22
|
else if ('createDriver' in driverOptions) {
|
|
16
23
|
this.logger.log('info', 'Reusing Kysely dialect provided via `driverOptions`');
|
|
17
|
-
this
|
|
24
|
+
this.#client = new Kysely({ dialect: driverOptions });
|
|
18
25
|
}
|
|
19
26
|
else {
|
|
20
|
-
this
|
|
21
|
-
dialect:
|
|
27
|
+
this.#client = new Kysely({
|
|
28
|
+
dialect: this.createKyselyDialect(driverOptions),
|
|
22
29
|
});
|
|
23
30
|
}
|
|
24
|
-
this.connected = true;
|
|
25
|
-
if (options?.skipOnConnect !== true) {
|
|
26
|
-
await this.onConnect();
|
|
27
|
-
}
|
|
28
31
|
}
|
|
29
32
|
/**
|
|
30
33
|
* @inheritDoc
|
|
31
34
|
*/
|
|
32
35
|
async close(force) {
|
|
33
36
|
await super.close(force);
|
|
34
|
-
await this
|
|
37
|
+
await this.#client?.destroy();
|
|
35
38
|
this.connected = false;
|
|
39
|
+
this.#client = undefined;
|
|
36
40
|
}
|
|
37
41
|
/**
|
|
38
42
|
* @inheritDoc
|
|
@@ -49,7 +53,7 @@ export class AbstractSqlConnection extends Connection {
|
|
|
49
53
|
return { ok: false, reason: 'Connection not established' };
|
|
50
54
|
}
|
|
51
55
|
try {
|
|
52
|
-
await this.
|
|
56
|
+
await this.getClient().executeQuery(CompiledQuery.raw('select 1'));
|
|
53
57
|
return { ok: true };
|
|
54
58
|
}
|
|
55
59
|
catch (error) {
|
|
@@ -57,7 +61,10 @@ export class AbstractSqlConnection extends Connection {
|
|
|
57
61
|
}
|
|
58
62
|
}
|
|
59
63
|
getClient() {
|
|
60
|
-
|
|
64
|
+
if (!this.#client) {
|
|
65
|
+
this.createKysely();
|
|
66
|
+
}
|
|
67
|
+
return this.#client;
|
|
61
68
|
}
|
|
62
69
|
async transactional(cb, options = {}) {
|
|
63
70
|
const trx = await this.begin(options);
|
|
@@ -86,7 +93,7 @@ export class AbstractSqlConnection extends Connection {
|
|
|
86
93
|
}
|
|
87
94
|
await this.ensureConnection();
|
|
88
95
|
await options.eventBroadcaster?.dispatchEvent(EventType.beforeTransactionStart);
|
|
89
|
-
let trxBuilder = this.
|
|
96
|
+
let trxBuilder = this.getClient().startTransaction();
|
|
90
97
|
if (options.isolationLevel) {
|
|
91
98
|
trxBuilder = trxBuilder.setIsolationLevel(options.isolationLevel);
|
|
92
99
|
}
|
|
@@ -155,7 +162,7 @@ export class AbstractSqlConnection extends Connection {
|
|
|
155
162
|
const sql = this.getSql(q.query, q.formatted, loggerContext);
|
|
156
163
|
return this.executeQuery(sql, async () => {
|
|
157
164
|
const compiled = CompiledQuery.raw(q.formatted);
|
|
158
|
-
const res = await (ctx ?? this
|
|
165
|
+
const res = await (ctx ?? this.#client).executeQuery(compiled);
|
|
159
166
|
return this.transformRawResult(res, method);
|
|
160
167
|
}, { ...q, ...loggerContext });
|
|
161
168
|
}
|
|
@@ -172,7 +179,7 @@ export class AbstractSqlConnection extends Connection {
|
|
|
172
179
|
parameters: [],
|
|
173
180
|
};
|
|
174
181
|
try {
|
|
175
|
-
const res = (ctx ?? this.
|
|
182
|
+
const res = (ctx ?? this.getClient()).getExecutor().stream(compiled, 1);
|
|
176
183
|
this.logQuery(sql, {
|
|
177
184
|
sql, params,
|
|
178
185
|
...loggerContext,
|
|
@@ -189,16 +196,12 @@ export class AbstractSqlConnection extends Connection {
|
|
|
189
196
|
throw e;
|
|
190
197
|
}
|
|
191
198
|
}
|
|
192
|
-
/**
|
|
193
|
-
|
|
194
|
-
*/
|
|
195
|
-
async loadFile(path) {
|
|
199
|
+
/** @inheritDoc */
|
|
200
|
+
async executeDump(dump) {
|
|
196
201
|
await this.ensureConnection();
|
|
197
|
-
const { readFile } = globalThis.process.getBuiltinModule('node:fs/promises');
|
|
198
|
-
const buf = await readFile(path);
|
|
199
202
|
try {
|
|
200
|
-
const raw = CompiledQuery.raw(
|
|
201
|
-
await this.
|
|
203
|
+
const raw = CompiledQuery.raw(dump);
|
|
204
|
+
await this.getClient().executeQuery(raw);
|
|
202
205
|
}
|
|
203
206
|
catch (e) {
|
|
204
207
|
/* v8 ignore next */
|
package/AbstractSqlDriver.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
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';
|
|
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 PopulatePath, type Primary, type QueryOrderMap, type QueryResult, type Raw, RawQueryFragment, type StreamOptions, type Transaction, type UpsertManyOptions, type UpsertOptions } from '@mikro-orm/core';
|
|
2
2
|
import type { AbstractSqlConnection } from './AbstractSqlConnection.js';
|
|
3
3
|
import type { AbstractSqlPlatform } from './AbstractSqlPlatform.js';
|
|
4
4
|
import { QueryBuilder } from './query/QueryBuilder.js';
|
|
5
5
|
import { type NativeQueryBuilder } from './query/NativeQueryBuilder.js';
|
|
6
6
|
import { QueryType } from './query/enums.js';
|
|
7
7
|
import { SqlEntityManager } from './SqlEntityManager.js';
|
|
8
|
-
import type {
|
|
8
|
+
import type { InternalField } from './typings.js';
|
|
9
9
|
export declare abstract class AbstractSqlDriver<Connection extends AbstractSqlConnection = AbstractSqlConnection, Platform extends AbstractSqlPlatform = AbstractSqlPlatform> extends DatabaseDriver<Connection> {
|
|
10
10
|
[EntityManagerType]: SqlEntityManager<this>;
|
|
11
11
|
protected readonly connection: Connection;
|
|
@@ -13,25 +13,42 @@ export declare abstract class AbstractSqlDriver<Connection extends AbstractSqlCo
|
|
|
13
13
|
protected readonly platform: Platform;
|
|
14
14
|
protected constructor(config: Configuration, platform: Platform, connection: Constructor<Connection>, connector: string[]);
|
|
15
15
|
getPlatform(): Platform;
|
|
16
|
+
/** Evaluates a formula callback, handling both string and Raw return values. */
|
|
17
|
+
evaluateFormula(formula: (...args: any[]) => string | Raw, columns: any, table: FormulaTable): string;
|
|
18
|
+
/** For TPT entities, returns ownProps (columns in this table); otherwise returns all props. */
|
|
19
|
+
private getTableProps;
|
|
20
|
+
/** Creates a FormulaTable object for use in formula callbacks. */
|
|
21
|
+
private createFormulaTable;
|
|
16
22
|
createEntityManager(useContext?: boolean): this[typeof EntityManagerType];
|
|
17
23
|
private createQueryBuilderFromOptions;
|
|
18
|
-
find<T extends object, P extends string = never, F extends string = PopulatePath.ALL, E extends string = never>(entityName:
|
|
19
|
-
findOne<T extends object, P extends string = never, F extends string = PopulatePath.ALL, E extends string = never>(entityName:
|
|
24
|
+
find<T extends object, P extends string = never, F extends string = PopulatePath.ALL, E extends string = never>(entityName: EntityName<T>, where: ObjectQuery<T>, options?: FindOptions<T, P, F, E>): Promise<EntityData<T>[]>;
|
|
25
|
+
findOne<T extends object, P extends string = never, F extends string = PopulatePath.ALL, E extends string = never>(entityName: EntityName<T>, where: ObjectQuery<T>, options?: FindOneOptions<T, P, F, E>): Promise<EntityData<T> | null>;
|
|
20
26
|
protected hasToManyJoins<T extends object>(hint: PopulateOptions<T>, meta: EntityMetadata<T>): boolean;
|
|
21
|
-
findVirtual<T extends object>(entityName:
|
|
22
|
-
countVirtual<T extends object>(entityName:
|
|
23
|
-
protected findFromVirtual<T extends object>(entityName:
|
|
27
|
+
findVirtual<T extends object>(entityName: EntityName<T>, where: ObjectQuery<T>, options: FindOptions<T, any, any, any>): Promise<EntityData<T>[]>;
|
|
28
|
+
countVirtual<T extends object>(entityName: EntityName<T>, where: ObjectQuery<T>, options: CountOptions<T, any>): Promise<number>;
|
|
29
|
+
protected findFromVirtual<T extends object>(entityName: EntityName<T>, where: ObjectQuery<T>, options: FindOptions<T, any> | CountOptions<T, any>, type: QueryType): Promise<EntityData<T>[] | number>;
|
|
24
30
|
protected streamFromVirtual<T extends object>(entityName: EntityName<T>, where: FilterQuery<T>, options: StreamOptions<T, any>): AsyncIterableIterator<EntityData<T>>;
|
|
25
31
|
protected wrapVirtualExpressionInSubquery<T extends object>(meta: EntityMetadata<T>, expression: string, where: FilterQuery<T>, options: FindOptions<T, any>, type: QueryType): Promise<T[] | number>;
|
|
26
32
|
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
33
|
mapResult<T extends object>(result: EntityData<T>, meta: EntityMetadata<T>, populate?: PopulateOptions<T>[], qb?: QueryBuilder<T, any, any, any>, map?: Dictionary): EntityData<T> | null;
|
|
34
|
+
/**
|
|
35
|
+
* Maps aliased columns from TPT parent tables back to their original field names.
|
|
36
|
+
* TPT parent columns are selected with aliases like `parent_alias__column_name`,
|
|
37
|
+
* and need to be renamed back to `column_name` for the result mapper to work.
|
|
38
|
+
*/
|
|
39
|
+
private mapTPTColumns;
|
|
28
40
|
private mapJoinedProps;
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
41
|
+
/**
|
|
42
|
+
* Maps a single property from a joined result row into the relation pojo.
|
|
43
|
+
* Handles polymorphic FKs, composite keys, Date parsing, and embedded objects.
|
|
44
|
+
*/
|
|
45
|
+
private mapJoinedProp;
|
|
46
|
+
count<T extends object>(entityName: EntityName<T>, where: any, options?: CountOptions<T>): Promise<number>;
|
|
47
|
+
nativeInsert<T extends object>(entityName: EntityName<T>, data: EntityDictionary<T>, options?: NativeInsertUpdateOptions<T>): Promise<QueryResult<T>>;
|
|
48
|
+
nativeInsertMany<T extends object>(entityName: EntityName<T>, data: EntityDictionary<T>[], options?: NativeInsertUpdateManyOptions<T>, transform?: (sql: string) => string): Promise<QueryResult<T>>;
|
|
49
|
+
nativeUpdate<T extends object>(entityName: EntityName<T>, where: FilterQuery<T>, data: EntityDictionary<T>, options?: NativeInsertUpdateOptions<T> & UpsertOptions<T>): Promise<QueryResult<T>>;
|
|
50
|
+
nativeUpdateMany<T extends object>(entityName: EntityName<T>, where: FilterQuery<T>[], data: EntityDictionary<T>[], options?: NativeInsertUpdateManyOptions<T> & UpsertManyOptions<T>): Promise<QueryResult<T>>;
|
|
51
|
+
nativeDelete<T extends object>(entityName: EntityName<T>, where: FilterQuery<T> | string | any, options?: DeleteOptions<T>): Promise<QueryResult<T>>;
|
|
35
52
|
/**
|
|
36
53
|
* Fast comparison for collection snapshots that are represented by PK arrays.
|
|
37
54
|
* Compares scalars via `===` and fallbacks to Utils.equals()` for more complex types like Buffer.
|
|
@@ -40,6 +57,24 @@ export declare abstract class AbstractSqlDriver<Connection extends AbstractSqlCo
|
|
|
40
57
|
private comparePrimaryKeyArrays;
|
|
41
58
|
syncCollections<T extends object, O extends object>(collections: Iterable<Collection<T, O>>, options?: DriverMethodOptions): Promise<void>;
|
|
42
59
|
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[]>>;
|
|
60
|
+
/**
|
|
61
|
+
* Load from a polymorphic M:N pivot table.
|
|
62
|
+
*/
|
|
63
|
+
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[]>>;
|
|
64
|
+
/**
|
|
65
|
+
* Load from owner side of polymorphic M:N (e.g., Post -> Tags)
|
|
66
|
+
*/
|
|
67
|
+
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[]>>;
|
|
68
|
+
/**
|
|
69
|
+
* Load from inverse side of polymorphic M:N (e.g., Tag -> Posts)
|
|
70
|
+
* Uses single query with join via virtual relation on pivot.
|
|
71
|
+
*/
|
|
72
|
+
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[]>>;
|
|
73
|
+
/**
|
|
74
|
+
* Build a map from owner PKs to their related entities from pivot table results.
|
|
75
|
+
*/
|
|
76
|
+
private buildPivotResultMap;
|
|
77
|
+
private wrapPopulateFilter;
|
|
43
78
|
private getPivotOrderBy;
|
|
44
79
|
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
80
|
stream<T extends object>(entityName: EntityName<T>, where: FilterQuery<T>, options: StreamOptions<T, any, any, any>): AsyncIterableIterator<T>;
|
|
@@ -57,32 +92,55 @@ export declare abstract class AbstractSqlDriver<Connection extends AbstractSqlCo
|
|
|
57
92
|
* @internal
|
|
58
93
|
*/
|
|
59
94
|
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
|
|
61
|
-
protected getFieldsForJoinedLoad<T extends object>(qb: QueryBuilder<T, any, any, any>, meta: EntityMetadata<T>, options: FieldsForJoinedLoadOptions<T>):
|
|
95
|
+
protected shouldHaveColumn<T, U>(meta: EntityMetadata<T>, prop: EntityProperty<U>, populate: readonly PopulateOptions<U>[], fields?: readonly InternalField<U>[], exclude?: readonly InternalField<U>[]): boolean;
|
|
96
|
+
protected getFieldsForJoinedLoad<T extends object>(qb: QueryBuilder<T, any, any, any>, meta: EntityMetadata<T>, options: FieldsForJoinedLoadOptions<T>): InternalField<T>[];
|
|
97
|
+
/**
|
|
98
|
+
* Adds LEFT JOINs and fields for TPT polymorphic loading when populating a relation to a TPT base class.
|
|
99
|
+
* @internal
|
|
100
|
+
*/
|
|
101
|
+
protected addTPTPolymorphicJoinsForRelation<T extends object>(qb: QueryBuilder<T, any, any, any>, meta: EntityMetadata<T>, baseAlias: string, fields: InternalField<T>[]): void;
|
|
102
|
+
/**
|
|
103
|
+
* Find the alias for a TPT child table in the query builder.
|
|
104
|
+
* @internal
|
|
105
|
+
*/
|
|
106
|
+
protected findTPTChildAlias<T extends object>(qb: QueryBuilder<T, any, any, any>, childMeta: EntityMetadata): string | undefined;
|
|
107
|
+
/**
|
|
108
|
+
* Builds a CASE WHEN expression for TPT discriminator.
|
|
109
|
+
* Determines concrete entity type based on which child table has a non-null PK.
|
|
110
|
+
* @internal
|
|
111
|
+
*/
|
|
112
|
+
buildTPTDiscriminatorExpression(meta: EntityMetadata, descendants: EntityMetadata[], aliasMap: Dictionary<string>, baseAlias: string): Raw;
|
|
113
|
+
/**
|
|
114
|
+
* Maps TPT child-specific fields during hydration.
|
|
115
|
+
* When a relation points to a TPT base class, the actual entity might be a child class.
|
|
116
|
+
* This method reads the discriminator to determine the concrete type and maps child-specific fields.
|
|
117
|
+
* @internal
|
|
118
|
+
*/
|
|
119
|
+
protected mapTPTChildFields<T extends object>(relationPojo: EntityData<T>, meta: EntityMetadata<T>, relationAlias: string, qb: QueryBuilder<T, any, any, any>, root: EntityData<T>): void;
|
|
62
120
|
/**
|
|
63
121
|
* @internal
|
|
64
122
|
*/
|
|
65
|
-
mapPropToFieldNames<T extends object>(qb: QueryBuilder<T, any, any, any>, prop: EntityProperty<T>, tableAlias: string, explicitFields?: readonly
|
|
123
|
+
mapPropToFieldNames<T extends object>(qb: QueryBuilder<T, any, any, any, any, any>, prop: EntityProperty<T>, tableAlias: string, meta: EntityMetadata<T>, schema?: string, explicitFields?: readonly InternalField<T>[]): InternalField<T>[];
|
|
66
124
|
/** @internal */
|
|
67
125
|
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
126
|
protected resolveConnectionType(args: {
|
|
69
127
|
ctx?: Transaction;
|
|
70
128
|
connectionType?: ConnectionType;
|
|
71
129
|
}): ConnectionType;
|
|
72
|
-
protected extractManyToMany<T>(
|
|
73
|
-
protected processManyToMany<T extends object>(meta: EntityMetadata<T
|
|
130
|
+
protected extractManyToMany<T>(meta: EntityMetadata<T>, data: EntityDictionary<T>): EntityData<T>;
|
|
131
|
+
protected processManyToMany<T extends object>(meta: EntityMetadata<T>, pks: Primary<T>[], collections: EntityData<T>, clear: boolean, options?: DriverMethodOptions): Promise<void>;
|
|
74
132
|
lockPessimistic<T extends object>(entity: T, options: LockOptions): Promise<void>;
|
|
75
133
|
protected buildPopulateWhere<T extends object>(meta: EntityMetadata<T>, joinedProps: PopulateOptions<T>[], options: Pick<FindOptions<any>, 'populateWhere'>): ObjectQuery<T>;
|
|
76
134
|
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
135
|
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
136
|
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:
|
|
80
|
-
protected processField<T extends object>(meta: EntityMetadata<T>, prop: EntityProperty<T> | undefined, field: string, ret:
|
|
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'
|
|
137
|
+
protected normalizeFields<T extends object>(fields: InternalField<T>[], prefix?: string): string[];
|
|
138
|
+
protected processField<T extends object>(meta: EntityMetadata<T>, prop: EntityProperty<T> | undefined, field: string, ret: InternalField<T>[]): void;
|
|
139
|
+
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'>, schema?: string): InternalField<T>[];
|
|
82
140
|
}
|
|
83
141
|
interface FieldsForJoinedLoadOptions<T extends object> {
|
|
84
|
-
explicitFields?: readonly
|
|
85
|
-
exclude?: readonly
|
|
142
|
+
explicitFields?: readonly InternalField<T>[];
|
|
143
|
+
exclude?: readonly InternalField<T>[];
|
|
86
144
|
populate?: readonly PopulateOptions<T>[];
|
|
87
145
|
strategy?: Options['loadStrategy'];
|
|
88
146
|
populateWhere?: FindOptions<any>['populateWhere'];
|
|
@@ -90,5 +148,6 @@ interface FieldsForJoinedLoadOptions<T extends object> {
|
|
|
90
148
|
parentTableAlias: string;
|
|
91
149
|
parentJoinPath?: string;
|
|
92
150
|
count?: boolean;
|
|
151
|
+
schema?: string;
|
|
93
152
|
}
|
|
94
153
|
export {};
|