@mikro-orm/sql 7.0.15-dev.9 → 7.0.15

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 (89) hide show
  1. package/AbstractSqlConnection.d.ts +94 -58
  2. package/AbstractSqlConnection.js +235 -238
  3. package/AbstractSqlDriver.d.ts +410 -155
  4. package/AbstractSqlDriver.js +2100 -1972
  5. package/AbstractSqlPlatform.d.ts +86 -76
  6. package/AbstractSqlPlatform.js +169 -167
  7. package/PivotCollectionPersister.d.ts +33 -15
  8. package/PivotCollectionPersister.js +158 -160
  9. package/README.md +1 -1
  10. package/SqlEntityManager.d.ts +67 -22
  11. package/SqlEntityManager.js +54 -38
  12. package/SqlEntityRepository.d.ts +14 -14
  13. package/SqlEntityRepository.js +23 -23
  14. package/SqlMikroORM.d.ts +49 -8
  15. package/SqlMikroORM.js +8 -8
  16. package/dialects/mssql/MsSqlNativeQueryBuilder.d.ts +12 -12
  17. package/dialects/mssql/MsSqlNativeQueryBuilder.js +199 -201
  18. package/dialects/mysql/BaseMySqlPlatform.d.ts +65 -46
  19. package/dialects/mysql/BaseMySqlPlatform.js +137 -134
  20. package/dialects/mysql/MySqlExceptionConverter.d.ts +6 -6
  21. package/dialects/mysql/MySqlExceptionConverter.js +91 -77
  22. package/dialects/mysql/MySqlNativeQueryBuilder.d.ts +3 -3
  23. package/dialects/mysql/MySqlNativeQueryBuilder.js +66 -69
  24. package/dialects/mysql/MySqlSchemaHelper.d.ts +58 -39
  25. package/dialects/mysql/MySqlSchemaHelper.js +327 -319
  26. package/dialects/oracledb/OracleDialect.d.ts +81 -52
  27. package/dialects/oracledb/OracleDialect.js +155 -149
  28. package/dialects/oracledb/OracleNativeQueryBuilder.d.ts +12 -12
  29. package/dialects/oracledb/OracleNativeQueryBuilder.js +239 -243
  30. package/dialects/postgresql/BasePostgreSqlPlatform.d.ts +110 -107
  31. package/dialects/postgresql/BasePostgreSqlPlatform.js +370 -369
  32. package/dialects/postgresql/FullTextType.d.ts +10 -6
  33. package/dialects/postgresql/FullTextType.js +51 -51
  34. package/dialects/postgresql/PostgreSqlExceptionConverter.d.ts +5 -5
  35. package/dialects/postgresql/PostgreSqlExceptionConverter.js +55 -43
  36. package/dialects/postgresql/PostgreSqlNativeQueryBuilder.d.ts +1 -1
  37. package/dialects/postgresql/PostgreSqlNativeQueryBuilder.js +4 -4
  38. package/dialects/postgresql/PostgreSqlSchemaHelper.d.ts +117 -82
  39. package/dialects/postgresql/PostgreSqlSchemaHelper.js +748 -712
  40. package/dialects/sqlite/BaseSqliteConnection.d.ts +3 -5
  41. package/dialects/sqlite/BaseSqliteConnection.js +21 -19
  42. package/dialects/sqlite/NodeSqliteDialect.d.ts +1 -1
  43. package/dialects/sqlite/NodeSqliteDialect.js +23 -23
  44. package/dialects/sqlite/SqliteDriver.d.ts +1 -1
  45. package/dialects/sqlite/SqliteDriver.js +3 -3
  46. package/dialects/sqlite/SqliteExceptionConverter.d.ts +6 -6
  47. package/dialects/sqlite/SqliteExceptionConverter.js +67 -51
  48. package/dialects/sqlite/SqliteNativeQueryBuilder.d.ts +2 -2
  49. package/dialects/sqlite/SqliteNativeQueryBuilder.js +7 -7
  50. package/dialects/sqlite/SqlitePlatform.d.ts +64 -73
  51. package/dialects/sqlite/SqlitePlatform.js +143 -143
  52. package/dialects/sqlite/SqliteSchemaHelper.d.ts +78 -61
  53. package/dialects/sqlite/SqliteSchemaHelper.js +541 -522
  54. package/package.json +3 -3
  55. package/plugin/index.d.ts +42 -35
  56. package/plugin/index.js +43 -36
  57. package/plugin/transformer.d.ts +137 -95
  58. package/plugin/transformer.js +1012 -881
  59. package/query/ArrayCriteriaNode.d.ts +4 -4
  60. package/query/ArrayCriteriaNode.js +18 -18
  61. package/query/CriteriaNode.d.ts +35 -25
  62. package/query/CriteriaNode.js +142 -132
  63. package/query/CriteriaNodeFactory.d.ts +49 -6
  64. package/query/CriteriaNodeFactory.js +97 -94
  65. package/query/NativeQueryBuilder.d.ts +120 -120
  66. package/query/NativeQueryBuilder.js +507 -501
  67. package/query/ObjectCriteriaNode.d.ts +12 -12
  68. package/query/ObjectCriteriaNode.js +298 -282
  69. package/query/QueryBuilder.d.ts +1558 -906
  70. package/query/QueryBuilder.js +2346 -2217
  71. package/query/QueryBuilderHelper.d.ts +153 -72
  72. package/query/QueryBuilderHelper.js +1084 -1032
  73. package/query/ScalarCriteriaNode.d.ts +3 -3
  74. package/query/ScalarCriteriaNode.js +53 -46
  75. package/query/enums.d.ts +14 -14
  76. package/query/enums.js +14 -14
  77. package/query/raw.d.ts +16 -6
  78. package/query/raw.js +10 -10
  79. package/schema/DatabaseSchema.d.ts +74 -50
  80. package/schema/DatabaseSchema.js +359 -331
  81. package/schema/DatabaseTable.d.ts +96 -73
  82. package/schema/DatabaseTable.js +1046 -974
  83. package/schema/SchemaComparator.d.ts +70 -66
  84. package/schema/SchemaComparator.js +790 -765
  85. package/schema/SchemaHelper.d.ts +128 -97
  86. package/schema/SchemaHelper.js +683 -668
  87. package/schema/SqlSchemaGenerator.d.ts +79 -59
  88. package/schema/SqlSchemaGenerator.js +525 -495
  89. package/typings.d.ts +405 -275
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mikro-orm/sql",
3
- "version": "7.0.15-dev.9",
3
+ "version": "7.0.15",
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.17"
51
51
  },
52
52
  "devDependencies": {
53
- "@mikro-orm/core": "^7.0.14"
53
+ "@mikro-orm/core": "^7.0.15"
54
54
  },
55
55
  "peerDependencies": {
56
- "@mikro-orm/core": "7.0.15-dev.9"
56
+ "@mikro-orm/core": "7.0.15"
57
57
  },
58
58
  "engines": {
59
59
  "node": ">= 22.17.0"
package/plugin/index.d.ts CHANGED
@@ -1,42 +1,49 @@
1
- import { type KyselyPlugin, type PluginTransformQueryArgs, type PluginTransformResultArgs, type QueryResult, type RootOperationNode, type UnknownRow } from 'kysely';
1
+ import {
2
+ type KyselyPlugin,
3
+ type PluginTransformQueryArgs,
4
+ type PluginTransformResultArgs,
5
+ type QueryResult,
6
+ type RootOperationNode,
7
+ type UnknownRow,
8
+ } from 'kysely';
2
9
  import type { SqlEntityManager } from '../SqlEntityManager.js';
3
10
  /** Configuration options for the MikroKyselyPlugin. */
4
11
  export interface MikroKyselyPluginOptions {
5
- /**
6
- * Use database table names ('table') or entity names ('entity') in queries.
7
- *
8
- * @default 'table'
9
- */
10
- tableNamingStrategy?: 'table' | 'entity';
11
- /**
12
- * Use database column names ('column') or property names ('property') in queries.
13
- *
14
- * @default 'column'
15
- */
16
- columnNamingStrategy?: 'column' | 'property';
17
- /**
18
- * Automatically process entity `onCreate` hooks in INSERT queries.
19
- *
20
- * @default false
21
- */
22
- processOnCreateHooks?: boolean;
23
- /**
24
- * Automatically process entity `onUpdate` hooks in UPDATE queries.
25
- *
26
- * @default false
27
- */
28
- processOnUpdateHooks?: boolean;
29
- /**
30
- * Convert JavaScript values to database-compatible values (e.g., Date to timestamp, custom types).
31
- *
32
- * @default false
33
- */
34
- convertValues?: boolean;
12
+ /**
13
+ * Use database table names ('table') or entity names ('entity') in queries.
14
+ *
15
+ * @default 'table'
16
+ */
17
+ tableNamingStrategy?: 'table' | 'entity';
18
+ /**
19
+ * Use database column names ('column') or property names ('property') in queries.
20
+ *
21
+ * @default 'column'
22
+ */
23
+ columnNamingStrategy?: 'column' | 'property';
24
+ /**
25
+ * Automatically process entity `onCreate` hooks in INSERT queries.
26
+ *
27
+ * @default false
28
+ */
29
+ processOnCreateHooks?: boolean;
30
+ /**
31
+ * Automatically process entity `onUpdate` hooks in UPDATE queries.
32
+ *
33
+ * @default false
34
+ */
35
+ processOnUpdateHooks?: boolean;
36
+ /**
37
+ * Convert JavaScript values to database-compatible values (e.g., Date to timestamp, custom types).
38
+ *
39
+ * @default false
40
+ */
41
+ convertValues?: boolean;
35
42
  }
36
43
  /** Kysely plugin that transforms queries and results to use MikroORM entity/property naming conventions. */
37
44
  export declare class MikroKyselyPlugin implements KyselyPlugin {
38
- #private;
39
- constructor(em: SqlEntityManager, options?: MikroKyselyPluginOptions);
40
- transformQuery(args: PluginTransformQueryArgs): RootOperationNode;
41
- transformResult(args: PluginTransformResultArgs): Promise<QueryResult<UnknownRow>>;
45
+ #private;
46
+ constructor(em: SqlEntityManager, options?: MikroKyselyPluginOptions);
47
+ transformQuery(args: PluginTransformQueryArgs): RootOperationNode;
48
+ transformResult(args: PluginTransformResultArgs): Promise<QueryResult<UnknownRow>>;
42
49
  }
package/plugin/index.js CHANGED
@@ -1,43 +1,50 @@
1
- import { SelectQueryNode as SelectQueryNodeClass, InsertQueryNode as InsertQueryNodeClass, UpdateQueryNode as UpdateQueryNodeClass, DeleteQueryNode as DeleteQueryNodeClass, } from 'kysely';
1
+ import {
2
+ SelectQueryNode as SelectQueryNodeClass,
3
+ InsertQueryNode as InsertQueryNodeClass,
4
+ UpdateQueryNode as UpdateQueryNodeClass,
5
+ DeleteQueryNode as DeleteQueryNodeClass,
6
+ } from 'kysely';
2
7
  import { MikroTransformer } from './transformer.js';
3
8
  /** Kysely plugin that transforms queries and results to use MikroORM entity/property naming conventions. */
4
9
  export class MikroKyselyPlugin {
5
- static #queryNodeCache = new WeakMap();
6
- #transformer;
7
- #options;
8
- constructor(em, options = {}) {
9
- this.#options = options;
10
- this.#transformer = new MikroTransformer(em, options);
10
+ static #queryNodeCache = new WeakMap();
11
+ #transformer;
12
+ #options;
13
+ constructor(em, options = {}) {
14
+ this.#options = options;
15
+ this.#transformer = new MikroTransformer(em, options);
16
+ }
17
+ transformQuery(args) {
18
+ this.#transformer.reset();
19
+ const result = this.#transformer.transformNode(args.node, args.queryId);
20
+ // Cache the entity map if it is one we can process (for use in transformResult)
21
+ if (
22
+ SelectQueryNodeClass.is(args.node) ||
23
+ InsertQueryNodeClass.is(args.node) ||
24
+ UpdateQueryNodeClass.is(args.node) ||
25
+ DeleteQueryNodeClass.is(args.node)
26
+ ) {
27
+ // clone the entityMap because the transformer's internal map will be cleared and reused by the next query
28
+ const entityMap = new Map(this.#transformer.getOutputEntityMap());
29
+ MikroKyselyPlugin.#queryNodeCache.set(args.queryId, { entityMap });
11
30
  }
12
- transformQuery(args) {
13
- this.#transformer.reset();
14
- const result = this.#transformer.transformNode(args.node, args.queryId);
15
- // Cache the entity map if it is one we can process (for use in transformResult)
16
- if (SelectQueryNodeClass.is(args.node) ||
17
- InsertQueryNodeClass.is(args.node) ||
18
- UpdateQueryNodeClass.is(args.node) ||
19
- DeleteQueryNodeClass.is(args.node)) {
20
- // clone the entityMap because the transformer's internal map will be cleared and reused by the next query
21
- const entityMap = new Map(this.#transformer.getOutputEntityMap());
22
- MikroKyselyPlugin.#queryNodeCache.set(args.queryId, { entityMap });
23
- }
24
- return result;
31
+ return result;
32
+ }
33
+ async transformResult(args) {
34
+ // Only transform results if columnNamingStrategy is 'property' or convertValues is true
35
+ if (this.#options.columnNamingStrategy !== 'property' && !this.#options.convertValues) {
36
+ return args.result;
25
37
  }
26
- async transformResult(args) {
27
- // Only transform results if columnNamingStrategy is 'property' or convertValues is true
28
- if (this.#options.columnNamingStrategy !== 'property' && !this.#options.convertValues) {
29
- return args.result;
30
- }
31
- // Retrieve the cached query node and metadata
32
- const cache = MikroKyselyPlugin.#queryNodeCache.get(args.queryId);
33
- if (!cache) {
34
- return args.result;
35
- }
36
- // Transform the result rows using the transformer
37
- const transformedRows = this.#transformer.transformResult(args.result.rows ?? [], cache.entityMap);
38
- return {
39
- ...args.result,
40
- rows: transformedRows ?? [],
41
- };
38
+ // Retrieve the cached query node and metadata
39
+ const cache = MikroKyselyPlugin.#queryNodeCache.get(args.queryId);
40
+ if (!cache) {
41
+ return args.result;
42
42
  }
43
+ // Transform the result rows using the transformer
44
+ const transformedRows = this.#transformer.transformResult(args.result.rows ?? [], cache.entityMap);
45
+ return {
46
+ ...args.result,
47
+ rows: transformedRows ?? [],
48
+ };
49
+ }
43
50
  }
@@ -1,99 +1,141 @@
1
- import { type EntityMetadata, type EntityProperty } from '@mikro-orm/core';
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';
1
+ import { type EntityMetadata, type EntityProperty, type Type } from '@mikro-orm/core';
2
+ import {
3
+ type CommonTableExpressionNameNode,
4
+ type DeleteQueryNode,
5
+ type InsertQueryNode,
6
+ type JoinNode,
7
+ type MergeQueryNode,
8
+ type OperationNode,
9
+ type QueryId,
10
+ type SelectQueryNode,
11
+ type UpdateQueryNode,
12
+ type WithNode,
13
+ ColumnNode,
14
+ IdentifierNode,
15
+ OperationNodeTransformer,
16
+ SelectionNode,
17
+ TableNode,
18
+ ValueNode,
19
+ } from 'kysely';
3
20
  import type { MikroKyselyPluginOptions } from './index.js';
4
21
  import type { SqlEntityManager } from '../SqlEntityManager.js';
5
22
  export declare class MikroTransformer extends OperationNodeTransformer {
6
- #private;
7
- constructor(em: SqlEntityManager, options?: MikroKyselyPluginOptions);
8
- reset(): void;
9
- getOutputEntityMap(): Map<string, EntityMetadata>;
10
- /** @internal */
11
- getContextStack(): Map<string, EntityMetadata | undefined>[];
12
- /** @internal */
13
- getSubqueryAliasMap(): Map<string, EntityMetadata | undefined>;
14
- transformSelectQuery(node: SelectQueryNode, queryId: QueryId): SelectQueryNode;
15
- transformInsertQuery(node: InsertQueryNode, queryId?: QueryId): InsertQueryNode;
16
- transformUpdateQuery(node: UpdateQueryNode, queryId?: QueryId): UpdateQueryNode;
17
- transformDeleteQuery(node: DeleteQueryNode, queryId?: QueryId): DeleteQueryNode;
18
- transformMergeQuery(node: MergeQueryNode, queryId?: QueryId): MergeQueryNode;
19
- transformIdentifier(node: IdentifierNode, queryId: QueryId): IdentifierNode;
20
- /**
21
- * Find owner entity metadata for the current identifier in the context stack.
22
- * Supports both aliased and non-aliased table references.
23
- * Searches up the context stack to support correlated subqueries.
24
- * Also checks subquery/CTE aliases to resolve to their source tables.
25
- */
26
- findOwnerEntityInContext(): EntityMetadata | undefined;
27
- processOnCreateHooks(node: InsertQueryNode, meta: EntityMetadata): InsertQueryNode;
28
- processOnUpdateHooks(node: UpdateQueryNode, meta: EntityMetadata): UpdateQueryNode;
29
- processInsertValues(node: InsertQueryNode, meta: EntityMetadata): InsertQueryNode;
30
- processUpdateValues(node: UpdateQueryNode, meta: EntityMetadata): UpdateQueryNode;
31
- mapColumnsToProperties(columns: readonly ColumnNode[], meta: EntityMetadata): (EntityProperty | undefined)[];
32
- normalizeColumnName(identifier: IdentifierNode): string;
33
- findProperty(meta: EntityMetadata | undefined, columnName?: string): EntityProperty | undefined;
34
- shouldConvertValues(): boolean;
35
- prepareInputValue(prop: EntityProperty | undefined, value: unknown, enabled: boolean): unknown;
36
- /**
37
- * Look up a table name/alias in the context stack.
38
- * Searches from current scope (top of stack) to parent scopes (bottom).
39
- * This supports correlated subqueries and references to outer query tables.
40
- */
41
- lookupInContextStack(tableNameOrAlias: string): EntityMetadata | undefined;
42
- /**
43
- * Process WITH node (CTE definitions)
44
- */
45
- processWithNode(withNode: WithNode, context: Map<string, EntityMetadata | undefined>): void;
46
- /**
47
- * Extract CTE name from CommonTableExpressionNameNode
48
- */
49
- getCTEName(nameNode: CommonTableExpressionNameNode): string | undefined;
50
- /**
51
- * Process a FROM item (can be TableNode or AliasNode)
52
- */
53
- processFromItem(from: any, // OperationNode type - can be TableNode, AliasNode, or SelectQueryNode
54
- context: Map<string, EntityMetadata | undefined>): void;
55
- /**
56
- * Process a JOIN node
57
- */
58
- processJoinNode(join: JoinNode, context: Map<string, EntityMetadata | undefined>): void;
59
- /**
60
- * Extract the primary source table from a SELECT query
61
- * This helps resolve columns from subqueries to their original entity tables
62
- */
63
- extractSourceTableFromSelectQuery(selectQuery: SelectQueryNode): EntityMetadata | undefined;
64
- /**
65
- * Extract alias name from an alias node
66
- */
67
- extractAliasName(alias: any): string | undefined;
68
- /**
69
- * Extract table name from a TableNode
70
- */
71
- getTableName(node: TableNode | undefined): string | undefined;
72
- /**
73
- * Find entity metadata by table name or entity name
74
- */
75
- findEntityMetadata(name: string): EntityMetadata | undefined;
76
- /**
77
- * Transform result rows by mapping database column names to property names
78
- * This is called for SELECT queries when columnNamingStrategy is 'property'
79
- */
80
- transformResult(rows: Record<string, any>[] | undefined, entityMap: Map<string, EntityMetadata>): Record<string, any>[] | undefined;
81
- buildGlobalFieldMap(entityMap: Map<string, EntityMetadata>): Record<string, EntityProperty>;
82
- buildGlobalRelationFieldMap(entityMap: Map<string, EntityMetadata>): Record<string, string>;
83
- /**
84
- * Build a mapping from database field names to property objects
85
- * Format: { 'field_name': EntityProperty }
86
- */
87
- buildFieldToPropertyMap(meta: EntityMetadata, alias?: string): Record<string, EntityProperty>;
88
- /**
89
- * Build a mapping for relation fields
90
- * For ManyToOne relations, we need to map from the foreign key field to the relation property
91
- * Format: { 'foreign_key_field': 'relationPropertyName' }
92
- */
93
- buildRelationFieldMap(meta: EntityMetadata, alias?: string): Record<string, string>;
94
- /**
95
- * Transform a single row by mapping column names to property names
96
- */
97
- transformRow(row: Record<string, any>, fieldToPropertyMap: Record<string, EntityProperty>, relationFieldMap: Record<string, string>): Record<string, any>;
98
- prepareOutputValue(prop: EntityProperty | undefined, value: unknown): unknown;
23
+ #private;
24
+ constructor(em: SqlEntityManager, options?: MikroKyselyPluginOptions);
25
+ reset(): void;
26
+ getOutputEntityMap(): Map<string, EntityMetadata>;
27
+ /** @internal */
28
+ getContextStack(): Map<string, EntityMetadata | undefined>[];
29
+ /** @internal */
30
+ getSubqueryAliasMap(): Map<string, EntityMetadata | undefined>;
31
+ transformSelectQuery(node: SelectQueryNode, queryId: QueryId): SelectQueryNode;
32
+ transformInsertQuery(node: InsertQueryNode, queryId?: QueryId): InsertQueryNode;
33
+ transformUpdateQuery(node: UpdateQueryNode, queryId?: QueryId): UpdateQueryNode;
34
+ transformDeleteQuery(node: DeleteQueryNode, queryId?: QueryId): DeleteQueryNode;
35
+ transformMergeQuery(node: MergeQueryNode, queryId?: QueryId): MergeQueryNode;
36
+ transformIdentifier(node: IdentifierNode, queryId: QueryId): IdentifierNode;
37
+ /**
38
+ * Find owner entity metadata for the current identifier in the context stack.
39
+ * Supports both aliased and non-aliased table references.
40
+ * Searches up the context stack to support correlated subqueries.
41
+ * Also checks subquery/CTE aliases to resolve to their source tables.
42
+ */
43
+ findOwnerEntityInContext(): EntityMetadata | undefined;
44
+ processOnCreateHooks(node: InsertQueryNode, meta: EntityMetadata): InsertQueryNode;
45
+ processOnUpdateHooks(node: UpdateQueryNode, meta: EntityMetadata): UpdateQueryNode;
46
+ processInsertValues(node: InsertQueryNode, meta: EntityMetadata): InsertQueryNode;
47
+ processUpdateValues(node: UpdateQueryNode, meta: EntityMetadata): UpdateQueryNode;
48
+ processInputValueNode(
49
+ prop: EntityProperty | undefined,
50
+ fieldName: string | undefined,
51
+ valueNode: ValueNode,
52
+ ): OperationNode;
53
+ expandSelections(selections: readonly SelectionNode[]): readonly SelectionNode[];
54
+ expandSelection(sel: SelectionNode): SelectionNode[] | null;
55
+ expandStar(
56
+ meta: EntityMetadata | undefined,
57
+ table: TableNode | undefined,
58
+ tableName: string | undefined,
59
+ ): SelectionNode[] | null;
60
+ wrapRead(customType: Type<any>, fieldName: string, tableName: string | undefined): SelectionNode;
61
+ wrapWrite(prop: EntityProperty | undefined, fieldName: string | undefined, valueNode: ValueNode): OperationNode;
62
+ /** Resolve the customType for a specific field name (handles composite-PK FK fan-out via prop.customTypes[]). */
63
+ fieldType(prop: EntityProperty, fieldName: string): Type<any> | undefined;
64
+ findOwnerMeta(name: string | undefined): EntityMetadata | undefined;
65
+ mapColumnsToProperties(columns: readonly ColumnNode[], meta: EntityMetadata): (EntityProperty | undefined)[];
66
+ normalizeColumnName(identifier: IdentifierNode): string;
67
+ findProperty(meta: EntityMetadata | undefined, columnName?: string): EntityProperty | undefined;
68
+ prepareInputValue(prop: EntityProperty | undefined, value: unknown, enabled: boolean): unknown;
69
+ /**
70
+ * Look up a table name/alias in the context stack.
71
+ * Searches from current scope (top of stack) to parent scopes (bottom).
72
+ * This supports correlated subqueries and references to outer query tables.
73
+ */
74
+ lookupInContextStack(tableNameOrAlias: string): EntityMetadata | undefined;
75
+ /**
76
+ * Process WITH node (CTE definitions)
77
+ */
78
+ processWithNode(withNode: WithNode, context: Map<string, EntityMetadata | undefined>): void;
79
+ /**
80
+ * Extract CTE name from CommonTableExpressionNameNode
81
+ */
82
+ getCTEName(nameNode: CommonTableExpressionNameNode): string | undefined;
83
+ /**
84
+ * Process a FROM item (can be TableNode or AliasNode)
85
+ */
86
+ processFromItem(
87
+ from: any, // OperationNode type - can be TableNode, AliasNode, or SelectQueryNode
88
+ context: Map<string, EntityMetadata | undefined>,
89
+ ): void;
90
+ /**
91
+ * Process a JOIN node
92
+ */
93
+ processJoinNode(join: JoinNode, context: Map<string, EntityMetadata | undefined>): void;
94
+ /**
95
+ * Extract the primary source table from a SELECT query
96
+ * This helps resolve columns from subqueries to their original entity tables
97
+ */
98
+ extractSourceTableFromSelectQuery(selectQuery: SelectQueryNode): EntityMetadata | undefined;
99
+ /**
100
+ * Extract alias name from an alias node
101
+ */
102
+ extractAliasName(alias: any): string | undefined;
103
+ /**
104
+ * Extract table name from a TableNode
105
+ */
106
+ getTableName(node: TableNode | undefined): string | undefined;
107
+ /**
108
+ * Find entity metadata by table name or entity name
109
+ */
110
+ findEntityMetadata(name: string): EntityMetadata | undefined;
111
+ /**
112
+ * Transform result rows by mapping database column names to property names
113
+ * This is called for SELECT queries when columnNamingStrategy is 'property'
114
+ */
115
+ transformResult(
116
+ rows: Record<string, any>[] | undefined,
117
+ entityMap: Map<string, EntityMetadata>,
118
+ ): Record<string, any>[] | undefined;
119
+ buildGlobalFieldMap(entityMap: Map<string, EntityMetadata>): Record<string, EntityProperty>;
120
+ buildGlobalRelationFieldMap(entityMap: Map<string, EntityMetadata>): Record<string, string>;
121
+ /**
122
+ * Build a mapping from database field names to property objects
123
+ * Format: { 'field_name': EntityProperty }
124
+ */
125
+ buildFieldToPropertyMap(meta: EntityMetadata, alias?: string): Record<string, EntityProperty>;
126
+ /**
127
+ * Build a mapping for relation fields
128
+ * For ManyToOne relations, we need to map from the foreign key field to the relation property
129
+ * Format: { 'foreign_key_field': 'relationPropertyName' }
130
+ */
131
+ buildRelationFieldMap(meta: EntityMetadata, alias?: string): Record<string, string>;
132
+ /**
133
+ * Transform a single row by mapping column names to property names
134
+ */
135
+ transformRow(
136
+ row: Record<string, any>,
137
+ fieldToPropertyMap: Record<string, EntityProperty>,
138
+ relationFieldMap: Record<string, string>,
139
+ ): Record<string, any>;
140
+ prepareOutputValue(prop: EntityProperty | undefined, value: unknown): unknown;
99
141
  }