@mikro-orm/sql 7.0.0-rc.3 → 7.0.1-dev.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 +5 -4
- package/AbstractSqlConnection.js +18 -5
- package/AbstractSqlDriver.d.ts +1 -1
- package/AbstractSqlDriver.js +39 -10
- package/AbstractSqlPlatform.d.ts +34 -0
- package/AbstractSqlPlatform.js +47 -3
- package/PivotCollectionPersister.d.ts +2 -11
- package/PivotCollectionPersister.js +59 -59
- package/README.md +5 -4
- package/SqlEntityManager.d.ts +1 -1
- package/dialects/index.d.ts +1 -0
- package/dialects/index.js +1 -0
- package/dialects/mysql/BaseMySqlPlatform.d.ts +6 -0
- package/dialects/mysql/BaseMySqlPlatform.js +17 -0
- package/dialects/mysql/MySqlSchemaHelper.d.ts +1 -1
- package/dialects/mysql/MySqlSchemaHelper.js +6 -6
- package/dialects/oracledb/OracleDialect.d.ts +78 -0
- package/dialects/oracledb/OracleDialect.js +166 -0
- package/dialects/oracledb/OracleNativeQueryBuilder.d.ts +19 -0
- package/dialects/oracledb/OracleNativeQueryBuilder.js +249 -0
- package/dialects/oracledb/index.d.ts +2 -0
- package/dialects/oracledb/index.js +2 -0
- package/dialects/postgresql/BasePostgreSqlPlatform.d.ts +6 -0
- package/dialects/postgresql/BasePostgreSqlPlatform.js +12 -8
- package/dialects/postgresql/PostgreSqlSchemaHelper.js +13 -13
- package/dialects/sqlite/SqlitePlatform.d.ts +1 -0
- package/dialects/sqlite/SqlitePlatform.js +3 -0
- package/dialects/sqlite/SqliteSchemaHelper.js +12 -8
- package/index.d.ts +1 -1
- package/index.js +0 -1
- package/package.json +3 -3
- package/plugin/index.d.ts +1 -14
- package/plugin/index.js +13 -13
- package/plugin/transformer.d.ts +6 -22
- package/plugin/transformer.js +81 -73
- package/query/ArrayCriteriaNode.d.ts +1 -1
- package/query/CriteriaNodeFactory.js +15 -3
- package/query/NativeQueryBuilder.d.ts +3 -3
- package/query/NativeQueryBuilder.js +4 -2
- package/query/ObjectCriteriaNode.js +4 -4
- package/query/QueryBuilder.d.ts +58 -62
- package/query/QueryBuilder.js +377 -370
- package/query/QueryBuilderHelper.d.ts +14 -11
- package/query/QueryBuilderHelper.js +324 -137
- package/query/ScalarCriteriaNode.js +3 -1
- package/query/enums.d.ts +2 -0
- package/query/enums.js +2 -0
- package/schema/DatabaseSchema.d.ts +7 -5
- package/schema/DatabaseSchema.js +50 -33
- package/schema/DatabaseTable.d.ts +8 -6
- package/schema/DatabaseTable.js +84 -60
- package/schema/SchemaComparator.d.ts +1 -3
- package/schema/SchemaComparator.js +22 -20
- package/schema/SchemaHelper.d.ts +2 -13
- package/schema/SchemaHelper.js +2 -1
- package/schema/SqlSchemaGenerator.d.ts +4 -14
- package/schema/SqlSchemaGenerator.js +15 -7
- package/typings.d.ts +4 -1
- package/tsconfig.build.tsbuildinfo +0 -1
|
@@ -19,7 +19,7 @@ export class PostgreSqlSchemaHelper extends SchemaHelper {
|
|
|
19
19
|
return `set names '${charset}';\n\n`;
|
|
20
20
|
}
|
|
21
21
|
getCreateDatabaseSQL(name) {
|
|
22
|
-
return `create database ${name}`;
|
|
22
|
+
return `create database ${this.quote(name)}`;
|
|
23
23
|
}
|
|
24
24
|
getListTablesSQL() {
|
|
25
25
|
return (`select table_name, table_schema as schema_name, ` +
|
|
@@ -152,7 +152,7 @@ export class PostgreSqlSchemaHelper extends SchemaHelper {
|
|
|
152
152
|
if (index.condeferrable) {
|
|
153
153
|
indexDef.deferMode = index.condeferred ? DeferMode.INITIALLY_DEFERRED : DeferMode.INITIALLY_IMMEDIATE;
|
|
154
154
|
}
|
|
155
|
-
if (index.index_def.some((col) =>
|
|
155
|
+
if (index.index_def.some((col) => /[(): ,"'`]/.exec(col)) || index.expression?.match(/ where /i)) {
|
|
156
156
|
indexDef.expression = index.expression;
|
|
157
157
|
}
|
|
158
158
|
if (index.deferrable) {
|
|
@@ -190,7 +190,7 @@ export class PostgreSqlSchemaHelper extends SchemaHelper {
|
|
|
190
190
|
// Extract just the column list from the expression (between first parens after USING)
|
|
191
191
|
// Pattern: ... USING method (...columns...) [INCLUDE (...)] [WHERE ...]
|
|
192
192
|
// Note: pg_get_indexdef always returns a valid expression with USING clause
|
|
193
|
-
const usingMatch =
|
|
193
|
+
const usingMatch = /using\s+\w+\s*\(/i.exec(expression);
|
|
194
194
|
const startIdx = usingMatch.index + usingMatch[0].length - 1; // Position of opening (
|
|
195
195
|
const columnsStr = this.extractParenthesizedContent(expression, startIdx);
|
|
196
196
|
// Use the column names from columnDefs and find their modifiers in the expression
|
|
@@ -209,12 +209,12 @@ export class PostgreSqlSchemaHelper extends SchemaHelper {
|
|
|
209
209
|
result.sort = 'DESC';
|
|
210
210
|
}
|
|
211
211
|
// Extract NULLS ordering
|
|
212
|
-
const nullsMatch =
|
|
212
|
+
const nullsMatch = /nulls\s+(first|last)/i.exec(modifiers);
|
|
213
213
|
if (nullsMatch) {
|
|
214
214
|
result.nulls = nullsMatch[1].toUpperCase();
|
|
215
215
|
}
|
|
216
216
|
// Extract collation
|
|
217
|
-
const collateMatch =
|
|
217
|
+
const collateMatch = /collate\s+"?([^"\s,)]+)"?/i.exec(modifiers);
|
|
218
218
|
if (collateMatch) {
|
|
219
219
|
result.collation = collateMatch[1];
|
|
220
220
|
}
|
|
@@ -333,7 +333,7 @@ export class PostgreSqlSchemaHelper extends SchemaHelper {
|
|
|
333
333
|
}
|
|
334
334
|
seen.add(dedupeKey);
|
|
335
335
|
ret[key] ??= [];
|
|
336
|
-
const m =
|
|
336
|
+
const m = /^check \(\((.*)\)\)$/is.exec(check.expression);
|
|
337
337
|
const def = m?.[1].replace(/\((.*?)\)::\w+/g, '$1');
|
|
338
338
|
ret[key].push({
|
|
339
339
|
name: check.name,
|
|
@@ -362,7 +362,7 @@ export class PostgreSqlSchemaHelper extends SchemaHelper {
|
|
|
362
362
|
const allFks = await connection.execute(sql);
|
|
363
363
|
const ret = {};
|
|
364
364
|
function mapReferentialIntegrity(value, def) {
|
|
365
|
-
const match = ['n', 'd'].includes(value) &&
|
|
365
|
+
const match = ['n', 'd'].includes(value) && /ON DELETE (SET (NULL|DEFAULT) \(.*?\))/.exec(def);
|
|
366
366
|
if (match) {
|
|
367
367
|
return match[1];
|
|
368
368
|
}
|
|
@@ -465,10 +465,10 @@ export class PostgreSqlSchemaHelper extends SchemaHelper {
|
|
|
465
465
|
let items;
|
|
466
466
|
/* v8 ignore next */
|
|
467
467
|
if (m3) {
|
|
468
|
-
items = m3.map((item) =>
|
|
468
|
+
items = m3.map((item) => /^\(?'(.*)'/.exec(item.trim())?.[1]);
|
|
469
469
|
}
|
|
470
470
|
else {
|
|
471
|
-
items = m2[1].split(',').map((item) =>
|
|
471
|
+
items = m2[1].split(',').map((item) => /^\(?'(.*)'/.exec(item.trim())?.[1]);
|
|
472
472
|
}
|
|
473
473
|
items = items.filter(item => item !== undefined);
|
|
474
474
|
if (items.length > 0) {
|
|
@@ -605,7 +605,7 @@ export class PostgreSqlSchemaHelper extends SchemaHelper {
|
|
|
605
605
|
if (!defaultValue || typeof defaultValue !== 'string') {
|
|
606
606
|
return super.normalizeDefaultValue(defaultValue, length, PostgreSqlSchemaHelper.DEFAULT_VALUES);
|
|
607
607
|
}
|
|
608
|
-
const match =
|
|
608
|
+
const match = /^'(.*)'::(.*)$/.exec(defaultValue);
|
|
609
609
|
if (match) {
|
|
610
610
|
if (match[2] === 'integer') {
|
|
611
611
|
return +match[1];
|
|
@@ -617,8 +617,8 @@ export class PostgreSqlSchemaHelper extends SchemaHelper {
|
|
|
617
617
|
appendComments(table) {
|
|
618
618
|
const sql = [];
|
|
619
619
|
if (table.comment) {
|
|
620
|
-
const comment = this.platform.quoteValue(table.comment)
|
|
621
|
-
sql.push(`comment on table ${table.getQuotedName()} is ${
|
|
620
|
+
const comment = this.platform.quoteValue(this.processComment(table.comment));
|
|
621
|
+
sql.push(`comment on table ${table.getQuotedName()} is ${comment}`);
|
|
622
622
|
}
|
|
623
623
|
for (const column of table.getColumns()) {
|
|
624
624
|
if (column.comment) {
|
|
@@ -723,7 +723,7 @@ export class PostgreSqlSchemaHelper extends SchemaHelper {
|
|
|
723
723
|
order by pgc.conname`;
|
|
724
724
|
}
|
|
725
725
|
inferLengthFromColumnType(type) {
|
|
726
|
-
const match =
|
|
726
|
+
const match = /^(\w+(?:\s+\w+)*)\s*(?:\(\s*(\d+)\s*\)|$)/.exec(type);
|
|
727
727
|
if (!match) {
|
|
728
728
|
return;
|
|
729
729
|
}
|
|
@@ -75,5 +75,6 @@ export declare class SqlitePlatform extends AbstractSqlPlatform {
|
|
|
75
75
|
convertVersionValue(value: Date | number, prop: EntityProperty): number | {
|
|
76
76
|
$in: (string | number)[];
|
|
77
77
|
};
|
|
78
|
+
getJsonArrayElementPropertySQL(alias: string, property: string, _type: string): string;
|
|
78
79
|
quoteValue(value: any): string;
|
|
79
80
|
}
|
|
@@ -133,6 +133,9 @@ export class SqlitePlatform extends AbstractSqlPlatform {
|
|
|
133
133
|
}
|
|
134
134
|
return value;
|
|
135
135
|
}
|
|
136
|
+
getJsonArrayElementPropertySQL(alias, property, _type) {
|
|
137
|
+
return `json_extract(${this.quoteIdentifier(alias)}.value, '$.${this.quoteJsonKey(property)}')`;
|
|
138
|
+
}
|
|
136
139
|
quoteValue(value) {
|
|
137
140
|
if (value instanceof Date) {
|
|
138
141
|
return '' + +value;
|
|
@@ -220,7 +220,7 @@ export class SqliteSchemaHelper extends SchemaHelper {
|
|
|
220
220
|
const columns = {};
|
|
221
221
|
const constraints = [];
|
|
222
222
|
// extract all columns definitions
|
|
223
|
-
let columnsDef =
|
|
223
|
+
let columnsDef = new RegExp(`create table [\`"']?.*?[\`"']? \\((.*)\\)`, 'i').exec(sql.replaceAll('\n', ''))?.[1];
|
|
224
224
|
/* v8 ignore next */
|
|
225
225
|
if (columnsDef) {
|
|
226
226
|
if (columnsDef.includes(', constraint ')) {
|
|
@@ -230,7 +230,7 @@ export class SqliteSchemaHelper extends SchemaHelper {
|
|
|
230
230
|
for (let i = cols.length - 1; i >= 0; i--) {
|
|
231
231
|
const col = cols[i];
|
|
232
232
|
const re = ` *, *[\`"']?${col.name}[\`"']? (.*)`;
|
|
233
|
-
const columnDef =
|
|
233
|
+
const columnDef = new RegExp(re, 'i').exec(columnsDef);
|
|
234
234
|
if (columnDef) {
|
|
235
235
|
columns[col.name] = { name: col.name, definition: columnDef[1] };
|
|
236
236
|
columnsDef = columnsDef.substring(0, columnDef.index);
|
|
@@ -260,7 +260,7 @@ export class SqliteSchemaHelper extends SchemaHelper {
|
|
|
260
260
|
* Extracts the SELECT part from a CREATE VIEW statement.
|
|
261
261
|
*/
|
|
262
262
|
extractViewDefinition(viewDefinition) {
|
|
263
|
-
const match =
|
|
263
|
+
const match = /create\s+view\s+[`"']?\w+[`"']?\s+as\s+(.*)/i.exec(viewDefinition);
|
|
264
264
|
/* v8 ignore next - fallback for non-standard view definitions */
|
|
265
265
|
return match ? match[1] : viewDefinition;
|
|
266
266
|
}
|
|
@@ -307,7 +307,11 @@ export class SqliteSchemaHelper extends SchemaHelper {
|
|
|
307
307
|
return null;
|
|
308
308
|
}
|
|
309
309
|
// simple values that are returned as-is from pragma (no wrapping needed)
|
|
310
|
-
if (/^-?\d/.test(value) ||
|
|
310
|
+
if (/^-?\d/.test(value) ||
|
|
311
|
+
/^[xX]'/.test(value) ||
|
|
312
|
+
value.startsWith("'") ||
|
|
313
|
+
value.startsWith('"') ||
|
|
314
|
+
value.startsWith('(')) {
|
|
311
315
|
return value;
|
|
312
316
|
}
|
|
313
317
|
const lower = value.toLowerCase();
|
|
@@ -325,10 +329,10 @@ export class SqliteSchemaHelper extends SchemaHelper {
|
|
|
325
329
|
return checkConstraints.reduce((o, item) => {
|
|
326
330
|
// check constraints are defined as (note that last closing paren is missing):
|
|
327
331
|
// `type` text check (`type` in ('local', 'global')
|
|
328
|
-
const match =
|
|
332
|
+
const match = /[`["']([^`\]"']+)[`\]"'] text check \(.* \((.*)\)/i.exec(item);
|
|
329
333
|
/* v8 ignore next */
|
|
330
334
|
if (match) {
|
|
331
|
-
o[match[1]] = match[2].split(',').map((item) =>
|
|
335
|
+
o[match[1]] = match[2].split(',').map((item) => /^\(?'(.*)'/.exec(item.trim())[1]);
|
|
332
336
|
}
|
|
333
337
|
return o;
|
|
334
338
|
}, {});
|
|
@@ -371,7 +375,7 @@ export class SqliteSchemaHelper extends SchemaHelper {
|
|
|
371
375
|
const checks = [];
|
|
372
376
|
for (const key of Object.keys(columns)) {
|
|
373
377
|
const column = columns[key];
|
|
374
|
-
const expression =
|
|
378
|
+
const expression = / (check \((.*)\))/i.exec(column.definition);
|
|
375
379
|
if (expression) {
|
|
376
380
|
checks.push({
|
|
377
381
|
name: this.platform.getConfig().getNamingStrategy().indexName(tableName, [column.name], 'check'),
|
|
@@ -382,7 +386,7 @@ export class SqliteSchemaHelper extends SchemaHelper {
|
|
|
382
386
|
}
|
|
383
387
|
}
|
|
384
388
|
for (const constraint of constraints) {
|
|
385
|
-
const expression =
|
|
389
|
+
const expression = /constraint *[`"']?(.*?)[`"']? * (check \((.*)\))/i.exec(constraint);
|
|
386
390
|
if (expression) {
|
|
387
391
|
checks.push({
|
|
388
392
|
name: expression[1],
|
package/index.d.ts
CHANGED
|
@@ -13,7 +13,7 @@ export * from './query/index.js';
|
|
|
13
13
|
export { raw } from './query/index.js';
|
|
14
14
|
export * from './schema/index.js';
|
|
15
15
|
export * from './dialects/index.js';
|
|
16
|
-
export * from './typings.js';
|
|
16
|
+
export type * from './typings.js';
|
|
17
17
|
export * from './plugin/index.js';
|
|
18
18
|
export { SqlEntityManager as EntityManager } from './SqlEntityManager.js';
|
|
19
19
|
export { SqlEntityRepository as EntityRepository } from './SqlEntityRepository.js';
|
package/index.js
CHANGED
|
@@ -13,7 +13,6 @@ export * from './query/index.js';
|
|
|
13
13
|
export { raw } from './query/index.js';
|
|
14
14
|
export * from './schema/index.js';
|
|
15
15
|
export * from './dialects/index.js';
|
|
16
|
-
export * from './typings.js';
|
|
17
16
|
export * from './plugin/index.js';
|
|
18
17
|
export { SqlEntityManager as EntityManager } from './SqlEntityManager.js';
|
|
19
18
|
export { SqlEntityRepository as EntityRepository } from './SqlEntityRepository.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mikro-orm/sql",
|
|
3
|
-
"version": "7.0.
|
|
3
|
+
"version": "7.0.1-dev.0",
|
|
4
4
|
"description": "TypeScript ORM for Node.js based on Data Mapper, Unit of Work and Identity Map patterns. Supports MongoDB, MySQL, PostgreSQL and SQLite databases as well as usage with vanilla JavaScript.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"data-mapper",
|
|
@@ -50,10 +50,10 @@
|
|
|
50
50
|
"kysely": "0.28.11"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
|
-
"@mikro-orm/core": "^
|
|
53
|
+
"@mikro-orm/core": "^7.0.0"
|
|
54
54
|
},
|
|
55
55
|
"peerDependencies": {
|
|
56
|
-
"@mikro-orm/core": "7.0.
|
|
56
|
+
"@mikro-orm/core": "7.0.1-dev.0"
|
|
57
57
|
},
|
|
58
58
|
"engines": {
|
|
59
59
|
"node": ">= 22.17.0"
|
package/plugin/index.d.ts
CHANGED
|
@@ -1,14 +1,5 @@
|
|
|
1
1
|
import { type KyselyPlugin, type PluginTransformQueryArgs, type PluginTransformResultArgs, type QueryResult, type RootOperationNode, type UnknownRow } from 'kysely';
|
|
2
|
-
import { MikroTransformer } from './transformer.js';
|
|
3
2
|
import type { SqlEntityManager } from '../SqlEntityManager.js';
|
|
4
|
-
import type { EntityMetadata } from '@mikro-orm/core';
|
|
5
|
-
/**
|
|
6
|
-
* Cache for query transformation data
|
|
7
|
-
* Stores the query node and metadata about tables/aliases
|
|
8
|
-
*/
|
|
9
|
-
interface QueryTransformCache {
|
|
10
|
-
entityMap: Map<string, EntityMetadata>;
|
|
11
|
-
}
|
|
12
3
|
export interface MikroKyselyPluginOptions {
|
|
13
4
|
/**
|
|
14
5
|
* Use database table names ('table') or entity names ('entity') in queries.
|
|
@@ -42,12 +33,8 @@ export interface MikroKyselyPluginOptions {
|
|
|
42
33
|
convertValues?: boolean;
|
|
43
34
|
}
|
|
44
35
|
export declare class MikroKyselyPlugin implements KyselyPlugin {
|
|
45
|
-
|
|
46
|
-
protected readonly options: MikroKyselyPluginOptions;
|
|
47
|
-
protected static queryNodeCache: WeakMap<any, QueryTransformCache>;
|
|
48
|
-
protected readonly transformer: MikroTransformer;
|
|
36
|
+
#private;
|
|
49
37
|
constructor(em: SqlEntityManager, options?: MikroKyselyPluginOptions);
|
|
50
38
|
transformQuery(args: PluginTransformQueryArgs): RootOperationNode;
|
|
51
39
|
transformResult(args: PluginTransformResultArgs): Promise<QueryResult<UnknownRow>>;
|
|
52
40
|
}
|
|
53
|
-
export {};
|
package/plugin/index.js
CHANGED
|
@@ -1,39 +1,39 @@
|
|
|
1
1
|
import { SelectQueryNode as SelectQueryNodeClass, InsertQueryNode as InsertQueryNodeClass, UpdateQueryNode as UpdateQueryNodeClass, DeleteQueryNode as DeleteQueryNodeClass, } from 'kysely';
|
|
2
2
|
import { MikroTransformer } from './transformer.js';
|
|
3
3
|
export class MikroKyselyPlugin {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
transformer;
|
|
4
|
+
static #queryNodeCache = new WeakMap();
|
|
5
|
+
#transformer;
|
|
6
|
+
#options;
|
|
8
7
|
constructor(em, options = {}) {
|
|
9
|
-
this
|
|
10
|
-
this
|
|
11
|
-
this.transformer = new MikroTransformer(em, options);
|
|
8
|
+
this.#options = options;
|
|
9
|
+
this.#transformer = new MikroTransformer(em, options);
|
|
12
10
|
}
|
|
13
11
|
transformQuery(args) {
|
|
14
|
-
this
|
|
15
|
-
const result = this
|
|
12
|
+
this.#transformer.reset();
|
|
13
|
+
const result = this.#transformer.transformNode(args.node, args.queryId);
|
|
16
14
|
// Cache the entity map if it is one we can process (for use in transformResult)
|
|
17
15
|
if (SelectQueryNodeClass.is(args.node) ||
|
|
18
16
|
InsertQueryNodeClass.is(args.node) ||
|
|
19
17
|
UpdateQueryNodeClass.is(args.node) ||
|
|
20
18
|
DeleteQueryNodeClass.is(args.node)) {
|
|
21
|
-
|
|
19
|
+
// clone the entityMap because the transformer's internal map will be cleared and reused by the next query
|
|
20
|
+
const entityMap = new Map(this.#transformer.getOutputEntityMap());
|
|
21
|
+
MikroKyselyPlugin.#queryNodeCache.set(args.queryId, { entityMap });
|
|
22
22
|
}
|
|
23
23
|
return result;
|
|
24
24
|
}
|
|
25
25
|
async transformResult(args) {
|
|
26
26
|
// Only transform results if columnNamingStrategy is 'property' or convertValues is true
|
|
27
|
-
if (this
|
|
27
|
+
if (this.#options.columnNamingStrategy !== 'property' && !this.#options.convertValues) {
|
|
28
28
|
return args.result;
|
|
29
29
|
}
|
|
30
30
|
// Retrieve the cached query node and metadata
|
|
31
|
-
const cache = MikroKyselyPlugin
|
|
31
|
+
const cache = MikroKyselyPlugin.#queryNodeCache.get(args.queryId);
|
|
32
32
|
if (!cache) {
|
|
33
33
|
return args.result;
|
|
34
34
|
}
|
|
35
35
|
// Transform the result rows using the transformer
|
|
36
|
-
const transformedRows = this
|
|
36
|
+
const transformedRows = this.#transformer.transformResult(args.result.rows ?? [], cache.entityMap);
|
|
37
37
|
return {
|
|
38
38
|
...args.result,
|
|
39
39
|
rows: transformedRows ?? [],
|
package/plugin/transformer.d.ts
CHANGED
|
@@ -1,32 +1,16 @@
|
|
|
1
|
-
import { type EntityMetadata, type EntityProperty
|
|
1
|
+
import { type EntityMetadata, type EntityProperty } from '@mikro-orm/core';
|
|
2
2
|
import { type CommonTableExpressionNameNode, type DeleteQueryNode, type IdentifierNode, type InsertQueryNode, type JoinNode, type MergeQueryNode, type QueryId, type SelectQueryNode, type UpdateQueryNode, type WithNode, ColumnNode, OperationNodeTransformer, TableNode } from 'kysely';
|
|
3
3
|
import type { MikroKyselyPluginOptions } from './index.js';
|
|
4
4
|
import type { SqlEntityManager } from '../SqlEntityManager.js';
|
|
5
|
-
import type { AbstractSqlPlatform } from '../AbstractSqlPlatform.js';
|
|
6
5
|
export declare class MikroTransformer extends OperationNodeTransformer {
|
|
7
|
-
|
|
8
|
-
protected readonly options: MikroKyselyPluginOptions;
|
|
9
|
-
/**
|
|
10
|
-
* Context stack to support nested queries (subqueries, CTEs)
|
|
11
|
-
* Each level of query scope has its own Map of table aliases/names to EntityMetadata
|
|
12
|
-
* Top of stack (highest index) is the current scope
|
|
13
|
-
*/
|
|
14
|
-
protected readonly contextStack: Map<string, EntityMetadata | undefined>[];
|
|
15
|
-
/**
|
|
16
|
-
* Subquery alias map: maps subquery/CTE alias to its source table metadata
|
|
17
|
-
* Used to resolve columns from subqueries/CTEs to their original table definitions
|
|
18
|
-
*/
|
|
19
|
-
protected readonly subqueryAliasMap: Map<string, EntityMetadata | undefined>;
|
|
20
|
-
protected readonly metadata: MetadataStorage;
|
|
21
|
-
protected readonly platform: AbstractSqlPlatform;
|
|
22
|
-
/**
|
|
23
|
-
* Global map of all entities involved in the query.
|
|
24
|
-
* Populated during AST transformation and used for result transformation.
|
|
25
|
-
*/
|
|
26
|
-
protected readonly entityMap: Map<string, EntityMetadata<any, import("@mikro-orm/core").EntityCtor<any>>>;
|
|
6
|
+
#private;
|
|
27
7
|
constructor(em: SqlEntityManager, options?: MikroKyselyPluginOptions);
|
|
28
8
|
reset(): void;
|
|
29
9
|
getOutputEntityMap(): Map<string, EntityMetadata>;
|
|
10
|
+
/** @internal */
|
|
11
|
+
getContextStack(): Map<string, EntityMetadata | undefined>[];
|
|
12
|
+
/** @internal */
|
|
13
|
+
getSubqueryAliasMap(): Map<string, EntityMetadata | undefined>;
|
|
30
14
|
transformSelectQuery(node: SelectQueryNode, queryId: QueryId): SelectQueryNode;
|
|
31
15
|
transformInsertQuery(node: InsertQueryNode, queryId?: QueryId): InsertQueryNode;
|
|
32
16
|
transformUpdateQuery(node: UpdateQueryNode, queryId?: QueryId): UpdateQueryNode;
|