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