metal-orm 1.1.25 → 1.1.26

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/dist/index.cjs CHANGED
@@ -74,7 +74,6 @@ __export(index_exports, {
74
74
  DefaultMorphToReference: () => DefaultMorphToReference,
75
75
  DefaultTypeStrategy: () => DefaultTypeStrategy,
76
76
  DeleteQueryBuilder: () => DeleteQueryBuilder,
77
- DialectBase: () => DialectBase,
78
77
  DialectFactory: () => DialectFactory,
79
78
  DomainEventBus: () => DomainEventBus,
80
79
  Email: () => Email,
@@ -120,7 +119,6 @@ __export(index_exports, {
120
119
  RelationKinds: () => RelationKinds,
121
120
  STANDARD_COLUMN_TYPES: () => STANDARD_COLUMN_TYPES,
122
121
  SelectQueryBuilder: () => SelectQueryBuilder,
123
- SqlDialectBase: () => SqlDialectBase,
124
122
  SqlServerDialect: () => SqlServerDialect,
125
123
  SqliteDialect: () => SqliteDialect,
126
124
  SqliteReturningStrategy: () => SqliteReturningStrategy,
@@ -202,6 +200,7 @@ __export(index_exports, {
202
200
  columnToOpenApiSchema: () => columnToOpenApiSchema,
203
201
  columnTypeToOpenApiFormat: () => columnTypeToOpenApiFormat,
204
202
  columnTypeToOpenApiType: () => columnTypeToOpenApiType,
203
+ composeSqlDialect: () => composeSqlDialect,
205
204
  computePaginationMetadata: () => computePaginationMetadata,
206
205
  computeSchemaHash: () => computeSchemaHash,
207
206
  concat: () => concat,
@@ -221,11 +220,16 @@ __export(index_exports, {
221
220
  createExecutorFromQueryRunner: () => createExecutorFromQueryRunner,
222
221
  createMssqlCompilerSet: () => createMssqlCompilerSet,
223
222
  createMssqlExecutor: () => createMssqlExecutor,
223
+ createMySqlDialect: () => createMySqlDialect,
224
224
  createMysqlExecutor: () => createMysqlExecutor,
225
225
  createPooledExecutorFactory: () => createPooledExecutorFactory,
226
+ createPostgresDialect: () => createPostgresDialect,
226
227
  createPostgresExecutor: () => createPostgresExecutor,
227
228
  createQueryLoggingExecutor: () => createQueryLoggingExecutor,
228
229
  createRef: () => createRef,
230
+ createSqlDialect: () => createSqlDialect,
231
+ createSqlServerDialect: () => createSqlServerDialect,
232
+ createSqliteDialect: () => createSqliteDialect,
229
233
  createSqliteExecutor: () => createSqliteExecutor,
230
234
  createTediousExecutor: () => createTediousExecutor,
231
235
  createTediousMssqlClient: () => createTediousMssqlClient,
@@ -2004,159 +2008,6 @@ var SelectAstNormalizer = class {
2004
2008
  }
2005
2009
  };
2006
2010
 
2007
- // src/core/dialect/abstract.ts
2008
- var DialectBase = class _DialectBase {
2009
- expressionCompilerRegistry;
2010
- selectAstNormalizer;
2011
- functionStrategy;
2012
- tableFunctionStrategy;
2013
- constructor(functionStrategy, tableFunctionStrategy) {
2014
- this.functionStrategy = functionStrategy ?? new StandardFunctionStrategy();
2015
- this.tableFunctionStrategy = tableFunctionStrategy ?? new StandardTableFunctionStrategy();
2016
- this.selectAstNormalizer = new SelectAstNormalizer((kind) => this.supportsSetOperation(kind));
2017
- this.expressionCompilerRegistry = new ExpressionCompilerRegistry({
2018
- quoteIdentifier: (id) => this.quoteIdentifier(id),
2019
- compileSelectAst: (ast, ctx) => this.compileSelectAst(ast, ctx),
2020
- compileSelectForExists: (ast, ctx) => this.compileSelectForExists(ast, ctx),
2021
- compileJsonPath: (node) => this.compileJsonPath(node),
2022
- compileFunctionOperand: (node, ctx) => this.compileFunctionOperand(node, ctx),
2023
- describe: () => this.constructor.name
2024
- });
2025
- }
2026
- compileSelect(ast) {
2027
- const ctx = this.createCompilerContext();
2028
- const normalized = this.normalizeSelectAst(ast);
2029
- const rawSql = this.compileSelectAst(normalized, ctx).trim();
2030
- return {
2031
- sql: rawSql.endsWith(";") ? rawSql : `${rawSql};`,
2032
- params: [...ctx.params]
2033
- };
2034
- }
2035
- compileInsert(ast) {
2036
- const ctx = this.createCompilerContext();
2037
- const rawSql = this.compileInsertAst(ast, ctx).trim();
2038
- return {
2039
- sql: rawSql.endsWith(";") ? rawSql : `${rawSql};`,
2040
- params: [...ctx.params]
2041
- };
2042
- }
2043
- compileUpdate(ast) {
2044
- const ctx = this.createCompilerContext();
2045
- const rawSql = this.compileUpdateAst(ast, ctx).trim();
2046
- return {
2047
- sql: rawSql.endsWith(";") ? rawSql : `${rawSql};`,
2048
- params: [...ctx.params]
2049
- };
2050
- }
2051
- compileDelete(ast) {
2052
- const ctx = this.createCompilerContext();
2053
- const rawSql = this.compileDeleteAst(ast, ctx).trim();
2054
- return {
2055
- sql: rawSql.endsWith(";") ? rawSql : `${rawSql};`,
2056
- params: [...ctx.params]
2057
- };
2058
- }
2059
- supportsDmlReturningClause() {
2060
- return false;
2061
- }
2062
- compileWhere(where, ctx) {
2063
- if (!where) return "";
2064
- return ` WHERE ${this.compileExpression(where, ctx)}`;
2065
- }
2066
- compileReturning(returning, _ctx) {
2067
- void _ctx;
2068
- if (!returning || returning.length === 0) return "";
2069
- throw new Error("RETURNING is not supported by this dialect.");
2070
- }
2071
- compileSelectForExists(ast, ctx) {
2072
- const normalized = this.normalizeSelectAst(ast);
2073
- const full = this.compileSelectAst(normalized, ctx).trim().replace(/;$/, "");
2074
- if (normalized.setOps && normalized.setOps.length > 0) {
2075
- return `SELECT 1 FROM (${full}) AS _exists`;
2076
- }
2077
- const upper2 = full.toUpperCase();
2078
- const fromIndex = upper2.indexOf(" FROM ");
2079
- if (fromIndex === -1) return full;
2080
- return `SELECT 1${full.slice(fromIndex)}`;
2081
- }
2082
- createCompilerContext() {
2083
- const params = [];
2084
- let counter = 0;
2085
- return {
2086
- params,
2087
- addParameter: (value) => {
2088
- counter += 1;
2089
- params.push(value);
2090
- return this.formatPlaceholder(counter);
2091
- }
2092
- };
2093
- }
2094
- formatPlaceholder(_index) {
2095
- void _index;
2096
- return "?";
2097
- }
2098
- supportsSetOperation(_kind) {
2099
- void _kind;
2100
- return true;
2101
- }
2102
- normalizeSelectAst(ast) {
2103
- return this.selectAstNormalizer.normalize(ast);
2104
- }
2105
- registerExpressionCompiler(type, compiler) {
2106
- this.expressionCompilerRegistry.registerExpressionCompiler(type, compiler);
2107
- }
2108
- registerOperandCompiler(type, compiler) {
2109
- this.expressionCompilerRegistry.registerOperandCompiler(type, compiler);
2110
- }
2111
- compileExpression(node, ctx) {
2112
- return this.expressionCompilerRegistry.compileExpression(node, ctx);
2113
- }
2114
- compileOperand(node, ctx) {
2115
- return this.expressionCompilerRegistry.compileOperand(node, ctx);
2116
- }
2117
- compileOrderingTerm(term, ctx) {
2118
- return this.expressionCompilerRegistry.compileOrderingTerm(term, ctx);
2119
- }
2120
- compileJsonPath(_node) {
2121
- void _node;
2122
- throw new Error("JSON Path not supported by this dialect");
2123
- }
2124
- compileFunctionOperand(fnNode, ctx) {
2125
- const compiledArgs = fnNode.args.map((arg) => this.compileOperand(arg, ctx));
2126
- const renderer = this.functionStrategy.getRenderer(fnNode.name);
2127
- if (renderer) {
2128
- return renderer({
2129
- node: fnNode,
2130
- compiledArgs,
2131
- compileOperand: (operand) => this.compileOperand(operand, ctx)
2132
- });
2133
- }
2134
- return `${fnNode.name}(${compiledArgs.join(", ")})`;
2135
- }
2136
- /** Creates a minimal dialect implementation for isolated compiler tests. */
2137
- static create(functionStrategy, tableFunctionStrategy) {
2138
- class TestDialect extends _DialectBase {
2139
- dialect = "sqlite";
2140
- quoteIdentifier(id) {
2141
- return `"${id}"`;
2142
- }
2143
- compileSelectAst() {
2144
- throw new Error("Not implemented");
2145
- }
2146
- compileInsertAst() {
2147
- throw new Error("Not implemented");
2148
- }
2149
- compileUpdateAst() {
2150
- throw new Error("Not implemented");
2151
- }
2152
- compileDeleteAst() {
2153
- throw new Error("Not implemented");
2154
- }
2155
- }
2156
- return new TestDialect(functionStrategy, tableFunctionStrategy);
2157
- }
2158
- };
2159
-
2160
2011
  // src/core/dialect/base/pagination-strategy.ts
2161
2012
  var StandardLimitOffsetPagination = class {
2162
2013
  /**
@@ -2181,19 +2032,19 @@ var NoReturningStrategy = class {
2181
2032
  if (!returning || returning.length === 0) return "";
2182
2033
  throw new Error("RETURNING is not supported by this dialect.");
2183
2034
  }
2184
- formatReturningColumns(returning, quoteIdentifier) {
2035
+ formatReturningColumns(returning, quoteIdentifier5) {
2185
2036
  return returning.map((column) => {
2186
- const tablePart = column.table ? `${quoteIdentifier(column.table)}.` : "";
2187
- const aliasPart = column.alias ? ` AS ${quoteIdentifier(column.alias)}` : "";
2188
- return `${tablePart}${quoteIdentifier(column.name)}${aliasPart}`;
2037
+ const tablePart = column.table ? `${quoteIdentifier5(column.table)}.` : "";
2038
+ const aliasPart = column.alias ? ` AS ${quoteIdentifier5(column.alias)}` : "";
2039
+ return `${tablePart}${quoteIdentifier5(column.name)}${aliasPart}`;
2189
2040
  }).join(", ");
2190
2041
  }
2191
2042
  };
2192
2043
  var StandardReturningStrategy = class extends NoReturningStrategy {
2193
- compileReturning(returning, _ctx, quoteIdentifier) {
2044
+ compileReturning(returning, _ctx, quoteIdentifier5) {
2194
2045
  void _ctx;
2195
2046
  if (!returning || returning.length === 0) return "";
2196
- return ` RETURNING ${this.formatReturningColumns(returning, quoteIdentifier)}`;
2047
+ return ` RETURNING ${this.formatReturningColumns(returning, quoteIdentifier5)}`;
2197
2048
  }
2198
2049
  };
2199
2050
 
@@ -2324,13 +2175,13 @@ var CteCompiler = class {
2324
2175
  * @param stripTrailingSemicolon - Function to remove trailing semicolons from SQL.
2325
2176
  * @returns SQL WITH clause string (e.g., "WITH cte_name AS (...) ") or empty string if no CTEs.
2326
2177
  */
2327
- static compileCtes(ast, ctx, quoteIdentifier, compileSelectAst, normalizeSelectAst, stripTrailingSemicolon) {
2178
+ static compileCtes(ast, ctx, quoteIdentifier5, compileSelectAst, normalizeSelectAst, stripTrailingSemicolon) {
2328
2179
  if (!ast.ctes || ast.ctes.length === 0) return "";
2329
2180
  const hasRecursive = ast.ctes.some((cte) => cte.recursive);
2330
2181
  const prefix = hasRecursive ? "WITH RECURSIVE " : "WITH ";
2331
2182
  const cteDefs = ast.ctes.map((cte) => {
2332
- const name = quoteIdentifier(cte.name);
2333
- const cols = cte.columns && cte.columns.length ? `(${cte.columns.map((c) => quoteIdentifier(c)).join(", ")})` : "";
2183
+ const name = quoteIdentifier5(cte.name);
2184
+ const cols = cte.columns && cte.columns.length ? `(${cte.columns.map((c) => quoteIdentifier5(c)).join(", ")})` : "";
2334
2185
  const query = stripTrailingSemicolon(compileSelectAst(normalizeSelectAst(cte.query), ctx));
2335
2186
  return `${name}${cols} AS (${query})`;
2336
2187
  }).join(", ");
@@ -2553,138 +2404,174 @@ var StandardDeleteCompiler = class {
2553
2404
  }
2554
2405
  };
2555
2406
 
2556
- // src/core/dialect/base/sql-dialect.ts
2557
- var SqlDialectBase = class extends DialectBase {
2558
- paginationStrategy;
2559
- returningStrategy;
2560
- upsertStrategy;
2561
- dmlReturningSupported;
2562
- sourceCompiler;
2563
- standardUpdateCompiler;
2564
- compilerSet;
2565
- constructor(options = {}) {
2566
- super(options.functionStrategy, options.tableFunctionStrategy);
2567
- this.paginationStrategy = options.paginationStrategy ?? new StandardLimitOffsetPagination();
2568
- this.returningStrategy = options.returningStrategy ?? new NoReturningStrategy();
2569
- this.upsertStrategy = options.upsertStrategy ?? new NoUpsertStrategy();
2570
- this.dmlReturningSupported = options.supportsDmlReturning ?? false;
2571
- const services = {
2572
- getDialectName: () => this.dialect,
2573
- getPaginationStrategy: () => this.paginationStrategy,
2574
- getTableFunctionStrategy: () => this.tableFunctionStrategy,
2575
- quoteIdentifier: (id) => this.quoteIdentifier(id),
2576
- compileOperand: (node, ctx) => this.compileOperand(node, ctx),
2577
- compileExpression: (node, ctx) => this.compileExpression(node, ctx),
2578
- compileOrderingTerm: (term, ctx) => this.compileOrderingTerm(term, ctx),
2579
- normalizeSelectAst: (ast) => this.normalizeSelectAst(ast),
2580
- compileSelectAst: (ast, ctx) => this.compileSelectAst(ast, ctx),
2581
- compileReturning: (returning, ctx) => this.compileReturning(returning, ctx),
2582
- compileUpsertClause: (ast, ctx) => this.compileUpsertClause(ast, ctx),
2583
- compileSetTarget: (column, table) => this.compileSetTarget(column, table),
2584
- renderOrderByNulls: (order) => this.renderOrderByNulls(order),
2585
- renderOrderByCollation: (order) => this.renderOrderByCollation(order)
2586
- };
2587
- this.sourceCompiler = new StandardSqlSourceCompiler(services);
2588
- const standardSelect = new StandardSelectCompiler(services, this.sourceCompiler);
2589
- const standardInsert = new StandardInsertCompiler(services, this.sourceCompiler);
2590
- this.standardUpdateCompiler = new StandardUpdateCompiler(services, this.sourceCompiler);
2591
- const standardDelete = new StandardDeleteCompiler(services, this.sourceCompiler);
2592
- const overrides = options.compilerFactory?.({
2593
- services,
2594
- sources: this.sourceCompiler
2595
- }) ?? {};
2596
- this.compilerSet = {
2597
- select: overrides.select ?? standardSelect,
2598
- insert: overrides.insert ?? standardInsert,
2599
- update: overrides.update ?? this.standardUpdateCompiler,
2600
- delete: overrides.delete ?? standardDelete
2407
+ // src/core/dialect/base/sql-dialect-composer.ts
2408
+ var terminate = (sql) => {
2409
+ const trimmed = sql.trim();
2410
+ return trimmed.endsWith(";") ? trimmed : `${trimmed};`;
2411
+ };
2412
+ var composeSqlDialect = (config) => {
2413
+ const functionStrategy = config.functionStrategy ?? new StandardFunctionStrategy();
2414
+ const tableFunctionStrategy = config.tableFunctionStrategy ?? new StandardTableFunctionStrategy();
2415
+ const paginationStrategy = config.paginationStrategy ?? new StandardLimitOffsetPagination();
2416
+ const returningStrategy = config.returningStrategy ?? new NoReturningStrategy();
2417
+ const upsertStrategy = config.upsertStrategy ?? new NoUpsertStrategy();
2418
+ const selectAstNormalizer = new SelectAstNormalizer(
2419
+ (kind) => config.supportsSetOperation?.(kind) ?? true
2420
+ );
2421
+ let compilerSet;
2422
+ let expressionRegistry2;
2423
+ const createCompilerContext = () => {
2424
+ const params = [];
2425
+ let counter = 0;
2426
+ return {
2427
+ params,
2428
+ addParameter(value) {
2429
+ counter += 1;
2430
+ params.push(value);
2431
+ return config.formatPlaceholder?.(counter) ?? "?";
2432
+ }
2601
2433
  };
2602
- }
2603
- supportsDmlReturningClause() {
2604
- return this.dmlReturningSupported;
2605
- }
2606
- compileSelectAst(ast, ctx) {
2607
- return this.compilerSet.select.compile(ast, ctx);
2608
- }
2609
- compileInsertAst(ast, ctx) {
2610
- return this.compilerSet.insert.compile(ast, ctx);
2611
- }
2612
- compileUpdateAst(ast, ctx) {
2613
- return this.compilerSet.update.compile(ast, ctx);
2614
- }
2615
- compileDeleteAst(ast, ctx) {
2616
- return this.compilerSet.delete.compile(ast, ctx);
2617
- }
2618
- compileUpsertClause(ast, ctx) {
2619
- return this.upsertStrategy.compile(ast, ctx, {
2620
- getDialectName: () => this.dialect,
2621
- quoteIdentifier: (id) => this.quoteIdentifier(id),
2622
- compileOperand: (node, compilerContext) => this.compileOperand(node, compilerContext),
2623
- compileExpression: (node, compilerContext) => this.compileExpression(node, compilerContext),
2624
- compileUpdateAssignments: (assignments, table, compilerContext) => this.standardUpdateCompiler.compileAssignments(assignments, table, compilerContext)
2625
- });
2626
- }
2627
- compileReturning(returning, ctx) {
2628
- return this.returningStrategy.compileReturning(
2629
- returning,
2630
- ctx,
2631
- (id) => this.quoteIdentifier(id)
2632
- );
2633
- }
2634
- ensureConflictColumns(clause, message) {
2635
- if (!clause.target.columns.length) throw new Error(message);
2636
- }
2637
- compileUpdateAssignments(assignments, table, ctx) {
2638
- return this.standardUpdateCompiler.compileAssignments(assignments, table, ctx);
2639
- }
2640
- compileSetTarget(column, table) {
2641
- return this.compileQualifiedColumn(column, table);
2642
- }
2643
- compileQualifiedColumn(column, table) {
2644
- const baseTableName = table.name;
2645
- const alias = table.alias;
2646
- const columnTable = column.table ?? alias ?? baseTableName;
2647
- const tableQualifier = alias && column.table === baseTableName ? alias : columnTable;
2648
- if (!tableQualifier) return this.quoteIdentifier(column.name);
2649
- return `${this.quoteIdentifier(tableQualifier)}.${this.quoteIdentifier(column.name)}`;
2650
- }
2651
- formatReturningColumns(returning) {
2652
- return this.returningStrategy.formatReturningColumns(
2653
- returning,
2654
- (id) => this.quoteIdentifier(id)
2655
- );
2656
- }
2657
- compileFrom(source, ctx) {
2658
- return this.sourceCompiler.compileFrom(source, ctx);
2659
- }
2660
- compileFunctionTable(fn9, ctx) {
2661
- return this.sourceCompiler.compileFunctionTable(fn9, ctx);
2662
- }
2663
- compileDerivedTable(table, ctx) {
2664
- return this.sourceCompiler.compileDerivedTable(table, ctx);
2665
- }
2666
- compileTableSource(table) {
2667
- return this.sourceCompiler.compileTableSource(table);
2668
- }
2669
- compileTableName(table) {
2670
- return this.sourceCompiler.compileTableName(table);
2671
- }
2672
- compileTableReference(table) {
2673
- return this.sourceCompiler.compileTableReference(table);
2674
- }
2675
- stripTrailingSemicolon(sql) {
2676
- return this.sourceCompiler.stripTrailingSemicolon(sql);
2677
- }
2678
- wrapSetOperand(sql) {
2679
- return this.sourceCompiler.wrapSetOperand(sql);
2680
- }
2681
- renderOrderByNulls(order) {
2682
- return order.nulls ? ` NULLS ${order.nulls}` : "";
2683
- }
2684
- renderOrderByCollation(order) {
2685
- return order.collation ? ` COLLATE ${order.collation}` : "";
2686
- }
2434
+ };
2435
+ const compileSelectAst = (ast, ctx) => compilerSet.select.compile(ast, ctx);
2436
+ const normalizeSelectAst = (ast) => selectAstNormalizer.normalize(ast);
2437
+ const compileSelectForExists = (ast, ctx) => {
2438
+ const normalized = normalizeSelectAst(ast);
2439
+ const full = compileSelectAst(normalized, ctx).trim().replace(/;$/, "");
2440
+ if (normalized.setOps && normalized.setOps.length > 0) {
2441
+ return `SELECT 1 FROM (${full}) AS _exists`;
2442
+ }
2443
+ const fromIndex = full.toUpperCase().indexOf(" FROM ");
2444
+ return fromIndex === -1 ? full : `SELECT 1${full.slice(fromIndex)}`;
2445
+ };
2446
+ const compileJsonPath = (node) => {
2447
+ if (!config.compileJsonPath) {
2448
+ throw new Error(`JSON Path not supported by dialect "${config.name}".`);
2449
+ }
2450
+ return config.compileJsonPath(node);
2451
+ };
2452
+ const compileFunctionOperand = (node, ctx) => {
2453
+ const compiledArgs = node.args.map((arg) => expressionRegistry2.compileOperand(arg, ctx));
2454
+ const renderer = functionStrategy.getRenderer(node.name);
2455
+ if (renderer) {
2456
+ return renderer({
2457
+ node,
2458
+ compiledArgs,
2459
+ compileOperand: (operand) => expressionRegistry2.compileOperand(operand, ctx)
2460
+ });
2461
+ }
2462
+ return `${node.name}(${compiledArgs.join(", ")})`;
2463
+ };
2464
+ expressionRegistry2 = new ExpressionCompilerRegistry({
2465
+ quoteIdentifier: config.quoteIdentifier,
2466
+ compileSelectAst,
2467
+ compileSelectForExists,
2468
+ compileJsonPath,
2469
+ compileFunctionOperand,
2470
+ describe: () => config.describe ?? config.name
2471
+ });
2472
+ const compileSetTarget = (column, table) => {
2473
+ if (config.compileSetTarget) return config.compileSetTarget(column, table);
2474
+ const columnTable = column.table ?? table.alias ?? table.name;
2475
+ const tableQualifier = table.alias && column.table === table.name ? table.alias : columnTable;
2476
+ return tableQualifier ? `${config.quoteIdentifier(tableQualifier)}.${config.quoteIdentifier(column.name)}` : config.quoteIdentifier(column.name);
2477
+ };
2478
+ let standardUpdate;
2479
+ const services = {
2480
+ getDialectName: () => config.name,
2481
+ getPaginationStrategy: () => paginationStrategy,
2482
+ getTableFunctionStrategy: () => tableFunctionStrategy,
2483
+ quoteIdentifier: config.quoteIdentifier,
2484
+ compileOperand: (node, ctx) => expressionRegistry2.compileOperand(node, ctx),
2485
+ compileExpression: (node, ctx) => expressionRegistry2.compileExpression(node, ctx),
2486
+ compileOrderingTerm: (term, ctx) => expressionRegistry2.compileOrderingTerm(term, ctx),
2487
+ normalizeSelectAst,
2488
+ compileSelectAst,
2489
+ compileReturning: (returning, ctx) => returningStrategy.compileReturning(returning, ctx, config.quoteIdentifier),
2490
+ compileUpsertClause: (ast, ctx) => upsertStrategy.compile(ast, ctx, {
2491
+ getDialectName: () => config.name,
2492
+ quoteIdentifier: config.quoteIdentifier,
2493
+ compileOperand: (node, compilerContext) => expressionRegistry2.compileOperand(node, compilerContext),
2494
+ compileExpression: (node, compilerContext) => expressionRegistry2.compileExpression(node, compilerContext),
2495
+ compileUpdateAssignments: (assignments, table, compilerContext) => standardUpdate.compileAssignments(assignments, table, compilerContext)
2496
+ }),
2497
+ compileSetTarget,
2498
+ renderOrderByNulls: (order) => config.renderOrderByNulls?.(order) ?? (order.nulls ? ` NULLS ${order.nulls}` : ""),
2499
+ renderOrderByCollation: (order) => config.renderOrderByCollation?.(order) ?? (order.collation ? ` COLLATE ${order.collation}` : "")
2500
+ };
2501
+ const sources = new StandardSqlSourceCompiler(services);
2502
+ const standardSelect = new StandardSelectCompiler(services, sources);
2503
+ const standardInsert = new StandardInsertCompiler(services, sources);
2504
+ standardUpdate = new StandardUpdateCompiler(services, sources);
2505
+ const standardDelete = new StandardDeleteCompiler(services, sources);
2506
+ const overrides = config.compilerFactory?.({ services, sources }) ?? {};
2507
+ compilerSet = {
2508
+ select: overrides.select ?? standardSelect,
2509
+ insert: overrides.insert ?? standardInsert,
2510
+ update: overrides.update ?? standardUpdate,
2511
+ delete: overrides.delete ?? standardDelete
2512
+ };
2513
+ const expressionApi = {
2514
+ registerExpressionCompiler(type, compiler) {
2515
+ expressionRegistry2.registerExpressionCompiler(type, compiler);
2516
+ },
2517
+ registerOperandCompiler(type, compiler) {
2518
+ expressionRegistry2.registerOperandCompiler(type, compiler);
2519
+ },
2520
+ compileExpression(node, ctx) {
2521
+ return expressionRegistry2.compileExpression(node, ctx);
2522
+ },
2523
+ compileOperand(node, ctx) {
2524
+ return expressionRegistry2.compileOperand(node, ctx);
2525
+ },
2526
+ compileOrderingTerm(term, ctx) {
2527
+ return expressionRegistry2.compileOrderingTerm(term, ctx);
2528
+ }
2529
+ };
2530
+ config.configureExpressions?.(expressionApi);
2531
+ const dialect = {
2532
+ quoteIdentifier: config.quoteIdentifier,
2533
+ supportsDmlReturningClause: () => config.supportsDmlReturning ?? false,
2534
+ compileSelect(ast) {
2535
+ const ctx = createCompilerContext();
2536
+ return {
2537
+ sql: terminate(compileSelectAst(normalizeSelectAst(ast), ctx)),
2538
+ params: [...ctx.params]
2539
+ };
2540
+ },
2541
+ compileInsert(ast) {
2542
+ const ctx = createCompilerContext();
2543
+ return {
2544
+ sql: terminate(compilerSet.insert.compile(ast, ctx)),
2545
+ params: [...ctx.params]
2546
+ };
2547
+ },
2548
+ compileUpdate(ast) {
2549
+ const ctx = createCompilerContext();
2550
+ return {
2551
+ sql: terminate(compilerSet.update.compile(ast, ctx)),
2552
+ params: [...ctx.params]
2553
+ };
2554
+ },
2555
+ compileDelete(ast) {
2556
+ const ctx = createCompilerContext();
2557
+ return {
2558
+ sql: terminate(compilerSet.delete.compile(ast, ctx)),
2559
+ params: [...ctx.params]
2560
+ };
2561
+ }
2562
+ };
2563
+ const runtime = {
2564
+ quoteIdentifier: config.quoteIdentifier,
2565
+ createCompilerContext,
2566
+ compileOperand: (node, ctx) => expressionRegistry2.compileOperand(node, ctx),
2567
+ compileExpression: (node, ctx) => expressionRegistry2.compileExpression(node, ctx),
2568
+ compileOrderingTerm: (term, ctx) => expressionRegistry2.compileOrderingTerm(term, ctx),
2569
+ normalizeSelectAst,
2570
+ compileSelectAst
2571
+ };
2572
+ return { dialect, runtime };
2687
2573
  };
2574
+ var createSqlDialect = (config) => composeSqlDialect(config).dialect;
2688
2575
 
2689
2576
  // src/core/dialect/postgres/functions.ts
2690
2577
  var PostgresFunctionStrategy = class extends StandardFunctionStrategy {
@@ -2847,15 +2734,15 @@ var PostgresTableFunctionStrategy = class extends StandardTableFunctionStrategy
2847
2734
  this.registerOverrides();
2848
2735
  }
2849
2736
  registerOverrides() {
2850
- this.add("ARRAY_UNNEST", ({ node, compiledArgs, quoteIdentifier }) => {
2737
+ this.add("ARRAY_UNNEST", ({ node, compiledArgs, quoteIdentifier: quoteIdentifier5 }) => {
2851
2738
  const lateral = node.lateral ?? true;
2852
2739
  const withOrd = node.withOrdinality ?? false;
2853
2740
  const base = `unnest(${compiledArgs.join(", ")})${withOrd ? " WITH ORDINALITY" : ""}`;
2854
2741
  if (node.columnAliases?.length && !node.alias) {
2855
2742
  throw new Error("tvf(ARRAY_UNNEST) with columnAliases requires an alias.");
2856
2743
  }
2857
- const alias = node.alias ? ` AS ${quoteIdentifier(node.alias)}` : "";
2858
- const cols = node.columnAliases?.length ? `(${node.columnAliases.map(quoteIdentifier).join(", ")})` : "";
2744
+ const alias = node.alias ? ` AS ${quoteIdentifier5(node.alias)}` : "";
2745
+ const cols = node.columnAliases?.length ? `(${node.columnAliases.map(quoteIdentifier5).join(", ")})` : "";
2859
2746
  return `${lateral ? "LATERAL " : ""}${base}${alias}${cols}`;
2860
2747
  });
2861
2748
  }
@@ -2920,52 +2807,68 @@ var PostgresUpsertStrategy = class {
2920
2807
  };
2921
2808
 
2922
2809
  // src/core/dialect/postgres/index.ts
2923
- var PostgresDialect = class extends SqlDialectBase {
2924
- dialect = "postgres";
2925
- procedureCompiler;
2926
- constructor() {
2927
- super({
2928
- functionStrategy: new PostgresFunctionStrategy(),
2929
- tableFunctionStrategy: new PostgresTableFunctionStrategy(),
2930
- returningStrategy: new PostgresReturningStrategy(),
2931
- upsertStrategy: new PostgresUpsertStrategy(),
2932
- supportsDmlReturning: true
2933
- });
2934
- this.procedureCompiler = new PostgresProcedureCompiler({
2935
- quoteIdentifier: (id) => this.quoteIdentifier(id),
2936
- createCompilerContext: () => this.createCompilerContext(),
2937
- compileOperand: (node, ctx) => this.compileOperand(node, ctx)
2938
- });
2939
- this.registerExpressionCompiler("BitwiseExpression", (node, ctx) => {
2940
- const left2 = this.compileOperand(node.left, ctx);
2941
- const right2 = this.compileOperand(node.right, ctx);
2942
- const operator = node.operator === "^" ? "#" : node.operator;
2943
- return `${left2} ${operator} ${right2}`;
2944
- });
2945
- this.registerOperandCompiler("BitwiseExpression", (node, ctx) => {
2946
- const left2 = this.compileOperand(node.left, ctx);
2947
- const right2 = this.compileOperand(node.right, ctx);
2948
- const operator = node.operator === "^" ? "#" : node.operator;
2949
- return `(${left2} ${operator} ${right2})`;
2950
- });
2951
- }
2810
+ var quoteIdentifier = (id) => `"${id}"`;
2811
+ var createPostgresDialect = () => {
2812
+ const composition = composeSqlDialect({
2813
+ name: "postgres",
2814
+ quoteIdentifier,
2815
+ formatPlaceholder: (index) => `$${index}`,
2816
+ functionStrategy: new PostgresFunctionStrategy(),
2817
+ tableFunctionStrategy: new PostgresTableFunctionStrategy(),
2818
+ returningStrategy: new PostgresReturningStrategy(),
2819
+ upsertStrategy: new PostgresUpsertStrategy(),
2820
+ supportsDmlReturning: true,
2821
+ compileSetTarget: (column, _table) => {
2822
+ void _table;
2823
+ return quoteIdentifier(column.name);
2824
+ },
2825
+ compileJsonPath(node) {
2826
+ const column = `${quoteIdentifier(node.column.table)}.${quoteIdentifier(node.column.name)}`;
2827
+ return `${column}->>'${node.path}'`;
2828
+ },
2829
+ configureExpressions(api) {
2830
+ api.registerExpressionCompiler("BitwiseExpression", (node, ctx) => {
2831
+ const left2 = api.compileOperand(node.left, ctx);
2832
+ const right2 = api.compileOperand(node.right, ctx);
2833
+ const operator = node.operator === "^" ? "#" : node.operator;
2834
+ return `${left2} ${operator} ${right2}`;
2835
+ });
2836
+ api.registerOperandCompiler("BitwiseExpression", (node, ctx) => {
2837
+ const left2 = api.compileOperand(node.left, ctx);
2838
+ const right2 = api.compileOperand(node.right, ctx);
2839
+ const operator = node.operator === "^" ? "#" : node.operator;
2840
+ return `(${left2} ${operator} ${right2})`;
2841
+ });
2842
+ }
2843
+ });
2844
+ const procedures = new PostgresProcedureCompiler(composition.runtime);
2845
+ return {
2846
+ ...composition.dialect,
2847
+ compileProcedureCall: (ast) => procedures.compileProcedureCall(ast)
2848
+ };
2849
+ };
2850
+ var PostgresDialect = class {
2851
+ impl = createPostgresDialect();
2952
2852
  quoteIdentifier(id) {
2953
- return `"${id}"`;
2853
+ return this.impl.quoteIdentifier(id);
2954
2854
  }
2955
- formatPlaceholder(index) {
2956
- return `$${index}`;
2855
+ supportsDmlReturningClause() {
2856
+ return this.impl.supportsDmlReturningClause();
2957
2857
  }
2958
- compileJsonPath(node) {
2959
- const column = `${this.quoteIdentifier(node.column.table)}.${this.quoteIdentifier(node.column.name)}`;
2960
- return `${column}->>'${node.path}'`;
2858
+ compileSelect(ast) {
2859
+ return this.impl.compileSelect(ast);
2961
2860
  }
2962
- /** PostgreSQL requires unqualified column names in SET clauses. */
2963
- compileSetTarget(column, _table) {
2964
- void _table;
2965
- return this.quoteIdentifier(column.name);
2861
+ compileInsert(ast) {
2862
+ return this.impl.compileInsert(ast);
2863
+ }
2864
+ compileUpdate(ast) {
2865
+ return this.impl.compileUpdate(ast);
2866
+ }
2867
+ compileDelete(ast) {
2868
+ return this.impl.compileDelete(ast);
2966
2869
  }
2967
2870
  compileProcedureCall(ast) {
2968
- return this.procedureCompiler.compileProcedureCall(ast);
2871
+ return this.impl.compileProcedureCall(ast);
2969
2872
  }
2970
2873
  };
2971
2874
 
@@ -3145,38 +3048,57 @@ var MySqlUpsertStrategy = class {
3145
3048
  };
3146
3049
 
3147
3050
  // src/core/dialect/mysql/index.ts
3148
- var MySqlDialect = class extends SqlDialectBase {
3149
- dialect = "mysql";
3150
- procedureCompiler;
3151
- constructor() {
3152
- super({
3153
- functionStrategy: new MysqlFunctionStrategy(),
3154
- upsertStrategy: new MySqlUpsertStrategy()
3155
- });
3156
- this.procedureCompiler = new MySqlProcedureCompiler({
3157
- quoteIdentifier: (id) => this.quoteIdentifier(id),
3158
- createCompilerContext: () => this.createCompilerContext(),
3159
- compileOperand: (node, ctx) => this.compileOperand(node, ctx)
3160
- });
3161
- this.registerExpressionCompiler(
3162
- "IsDistinctExpression",
3163
- (node, ctx) => {
3164
- const left2 = this.compileOperand(node.left, ctx);
3165
- const right2 = this.compileOperand(node.right, ctx);
3166
- const spaceship = `${left2} <=> ${right2}`;
3167
- return node.operator === "IS NOT DISTINCT FROM" ? spaceship : `NOT (${spaceship})`;
3168
- }
3169
- );
3170
- }
3051
+ var quoteIdentifier2 = (id) => `\`${id}\``;
3052
+ var createMySqlDialect = () => {
3053
+ const composition = composeSqlDialect({
3054
+ name: "mysql",
3055
+ quoteIdentifier: quoteIdentifier2,
3056
+ functionStrategy: new MysqlFunctionStrategy(),
3057
+ upsertStrategy: new MySqlUpsertStrategy(),
3058
+ compileJsonPath(node) {
3059
+ const column = `${quoteIdentifier2(node.column.table)}.${quoteIdentifier2(node.column.name)}`;
3060
+ return `${column}->'${node.path}'`;
3061
+ },
3062
+ configureExpressions(api) {
3063
+ api.registerExpressionCompiler(
3064
+ "IsDistinctExpression",
3065
+ (node, ctx) => {
3066
+ const left2 = api.compileOperand(node.left, ctx);
3067
+ const right2 = api.compileOperand(node.right, ctx);
3068
+ const spaceship = `${left2} <=> ${right2}`;
3069
+ return node.operator === "IS NOT DISTINCT FROM" ? spaceship : `NOT (${spaceship})`;
3070
+ }
3071
+ );
3072
+ }
3073
+ });
3074
+ const procedures = new MySqlProcedureCompiler(composition.runtime);
3075
+ return {
3076
+ ...composition.dialect,
3077
+ compileProcedureCall: (ast) => procedures.compileProcedureCall(ast)
3078
+ };
3079
+ };
3080
+ var MySqlDialect = class {
3081
+ impl = createMySqlDialect();
3171
3082
  quoteIdentifier(id) {
3172
- return `\`${id}\``;
3083
+ return this.impl.quoteIdentifier(id);
3173
3084
  }
3174
- compileJsonPath(node) {
3175
- const column = `${this.quoteIdentifier(node.column.table)}.${this.quoteIdentifier(node.column.name)}`;
3176
- return `${column}->'${node.path}'`;
3085
+ supportsDmlReturningClause() {
3086
+ return this.impl.supportsDmlReturningClause();
3087
+ }
3088
+ compileSelect(ast) {
3089
+ return this.impl.compileSelect(ast);
3090
+ }
3091
+ compileInsert(ast) {
3092
+ return this.impl.compileInsert(ast);
3093
+ }
3094
+ compileUpdate(ast) {
3095
+ return this.impl.compileUpdate(ast);
3096
+ }
3097
+ compileDelete(ast) {
3098
+ return this.impl.compileDelete(ast);
3177
3099
  }
3178
3100
  compileProcedureCall(ast) {
3179
- return this.procedureCompiler.compileProcedureCall(ast);
3101
+ return this.impl.compileProcedureCall(ast);
3180
3102
  }
3181
3103
  };
3182
3104
 
@@ -3319,15 +3241,15 @@ var SqliteFunctionStrategy = class extends StandardFunctionStrategy {
3319
3241
 
3320
3242
  // src/core/dialect/sqlite/returning.ts
3321
3243
  var SqliteReturningStrategy = class {
3322
- compileReturning(returning, _ctx, quoteIdentifier) {
3244
+ compileReturning(returning, _ctx, quoteIdentifier5) {
3323
3245
  void _ctx;
3324
3246
  if (!returning || returning.length === 0) return "";
3325
- return ` RETURNING ${this.formatReturningColumns(returning, quoteIdentifier)}`;
3247
+ return ` RETURNING ${this.formatReturningColumns(returning, quoteIdentifier5)}`;
3326
3248
  }
3327
- formatReturningColumns(returning, quoteIdentifier) {
3249
+ formatReturningColumns(returning, quoteIdentifier5) {
3328
3250
  return returning.map((column) => {
3329
- const alias = column.alias ? ` AS ${quoteIdentifier(column.alias)}` : "";
3330
- return `${quoteIdentifier(column.name)}${alias}`;
3251
+ const alias = column.alias ? ` AS ${quoteIdentifier5(column.alias)}` : "";
3252
+ return `${quoteIdentifier5(column.name)}${alias}`;
3331
3253
  }).join(", ");
3332
3254
  }
3333
3255
  };
@@ -3358,42 +3280,60 @@ var SqliteUpsertStrategy = class {
3358
3280
  };
3359
3281
 
3360
3282
  // src/core/dialect/sqlite/index.ts
3361
- var SqliteDialect = class extends SqlDialectBase {
3362
- dialect = "sqlite";
3363
- constructor() {
3364
- super({
3365
- functionStrategy: new SqliteFunctionStrategy(),
3366
- returningStrategy: new SqliteReturningStrategy(),
3367
- upsertStrategy: new SqliteUpsertStrategy(),
3368
- supportsDmlReturning: true
3369
- });
3370
- this.registerExpressionCompiler("BitwiseExpression", (node, ctx) => {
3371
- const left2 = this.compileOperand(node.left, ctx);
3372
- const right2 = this.compileOperand(node.right, ctx);
3283
+ var quoteIdentifier3 = (id) => `"${id}"`;
3284
+ var createSqliteDialect = () => composeSqlDialect({
3285
+ name: "sqlite",
3286
+ quoteIdentifier: quoteIdentifier3,
3287
+ functionStrategy: new SqliteFunctionStrategy(),
3288
+ returningStrategy: new SqliteReturningStrategy(),
3289
+ upsertStrategy: new SqliteUpsertStrategy(),
3290
+ supportsDmlReturning: true,
3291
+ compileSetTarget: (column, _table) => {
3292
+ void _table;
3293
+ return quoteIdentifier3(column.name);
3294
+ },
3295
+ compileJsonPath(node) {
3296
+ const column = `${quoteIdentifier3(node.column.table)}.${quoteIdentifier3(node.column.name)}`;
3297
+ return `json_extract(${column}, '${node.path}')`;
3298
+ },
3299
+ configureExpressions(api) {
3300
+ api.registerExpressionCompiler("BitwiseExpression", (node, ctx) => {
3301
+ const left2 = api.compileOperand(node.left, ctx);
3302
+ const right2 = api.compileOperand(node.right, ctx);
3373
3303
  if (node.operator === "^") {
3374
3304
  return `(${left2} | ${right2}) & ~(${left2} & ${right2})`;
3375
3305
  }
3376
3306
  return `${left2} ${node.operator} ${right2}`;
3377
3307
  });
3378
- this.registerOperandCompiler("BitwiseExpression", (node, ctx) => {
3379
- const left2 = this.compileOperand(node.left, ctx);
3380
- const right2 = this.compileOperand(node.right, ctx);
3308
+ api.registerOperandCompiler("BitwiseExpression", (node, ctx) => {
3309
+ const left2 = api.compileOperand(node.left, ctx);
3310
+ const right2 = api.compileOperand(node.right, ctx);
3381
3311
  if (node.operator === "^") {
3382
3312
  return `((${left2} | ${right2}) & ~(${left2} & ${right2}))`;
3383
3313
  }
3384
3314
  return `(${left2} ${node.operator} ${right2})`;
3385
3315
  });
3386
3316
  }
3317
+ }).dialect;
3318
+ var SqliteDialect = class {
3319
+ impl = createSqliteDialect();
3387
3320
  quoteIdentifier(id) {
3388
- return `"${id}"`;
3321
+ return this.impl.quoteIdentifier(id);
3389
3322
  }
3390
- compileJsonPath(node) {
3391
- const column = `${this.quoteIdentifier(node.column.table)}.${this.quoteIdentifier(node.column.name)}`;
3392
- return `json_extract(${column}, '${node.path}')`;
3323
+ supportsDmlReturningClause() {
3324
+ return this.impl.supportsDmlReturningClause();
3393
3325
  }
3394
- compileQualifiedColumn(column, _table) {
3395
- void _table;
3396
- return this.quoteIdentifier(column.name);
3326
+ compileSelect(ast) {
3327
+ return this.impl.compileSelect(ast);
3328
+ }
3329
+ compileInsert(ast) {
3330
+ return this.impl.compileInsert(ast);
3331
+ }
3332
+ compileUpdate(ast) {
3333
+ return this.impl.compileUpdate(ast);
3334
+ }
3335
+ compileDelete(ast) {
3336
+ return this.impl.compileDelete(ast);
3397
3337
  }
3398
3338
  };
3399
3339
 
@@ -3523,22 +3463,22 @@ var MssqlFunctionStrategy = class extends StandardFunctionStrategy {
3523
3463
 
3524
3464
  // src/core/dialect/mssql/output.ts
3525
3465
  var MssqlOutputStrategy = class {
3526
- compileReturning(returning, _ctx, quoteIdentifier) {
3466
+ compileReturning(returning, _ctx, quoteIdentifier5) {
3527
3467
  void _ctx;
3528
- return this.compileOutput(returning, "inserted", quoteIdentifier);
3468
+ return this.compileOutput(returning, "inserted", quoteIdentifier5);
3529
3469
  }
3530
- compileOutput(returning, prefix, quoteIdentifier) {
3470
+ compileOutput(returning, prefix, quoteIdentifier5) {
3531
3471
  if (!returning || returning.length === 0) return "";
3532
3472
  const columns = returning.map((column) => {
3533
- const alias = column.alias ? ` AS ${quoteIdentifier(column.alias)}` : "";
3534
- return `${prefix}.${quoteIdentifier(column.name)}${alias}`;
3473
+ const alias = column.alias ? ` AS ${quoteIdentifier5(column.alias)}` : "";
3474
+ return `${prefix}.${quoteIdentifier5(column.name)}${alias}`;
3535
3475
  }).join(", ");
3536
3476
  return ` OUTPUT ${columns}`;
3537
3477
  }
3538
- formatReturningColumns(returning, quoteIdentifier) {
3478
+ formatReturningColumns(returning, quoteIdentifier5) {
3539
3479
  return returning.map((column) => {
3540
- const alias = column.alias ? ` AS ${quoteIdentifier(column.alias)}` : "";
3541
- return `${quoteIdentifier(column.name)}${alias}`;
3480
+ const alias = column.alias ? ` AS ${quoteIdentifier5(column.alias)}` : "";
3481
+ return `${quoteIdentifier5(column.name)}${alias}`;
3542
3482
  }).join(", ");
3543
3483
  }
3544
3484
  };
@@ -3820,34 +3760,49 @@ var MssqlProcedureCompiler = class {
3820
3760
  };
3821
3761
 
3822
3762
  // src/core/dialect/mssql/index.ts
3823
- var SqlServerDialect = class extends SqlDialectBase {
3824
- dialect = "mssql";
3825
- procedureCompiler;
3826
- constructor() {
3827
- super({
3828
- functionStrategy: new MssqlFunctionStrategy(),
3829
- returningStrategy: new MssqlOutputStrategy(),
3830
- compilerFactory: createMssqlCompilerSet,
3831
- supportsDmlReturning: true
3832
- });
3833
- this.procedureCompiler = new MssqlProcedureCompiler({
3834
- quoteIdentifier: (id) => this.quoteIdentifier(id),
3835
- createCompilerContext: () => this.createCompilerContext(),
3836
- compileOperand: (node, ctx) => this.compileOperand(node, ctx)
3837
- });
3838
- }
3763
+ var quoteIdentifier4 = (id) => `[${id}]`;
3764
+ var createSqlServerDialect = () => {
3765
+ const composition = composeSqlDialect({
3766
+ name: "mssql",
3767
+ quoteIdentifier: quoteIdentifier4,
3768
+ formatPlaceholder: (index) => `@p${index}`,
3769
+ functionStrategy: new MssqlFunctionStrategy(),
3770
+ returningStrategy: new MssqlOutputStrategy(),
3771
+ compilerFactory: createMssqlCompilerSet,
3772
+ supportsDmlReturning: true,
3773
+ compileJsonPath(node) {
3774
+ const column = `${quoteIdentifier4(node.column.table)}.${quoteIdentifier4(node.column.name)}`;
3775
+ return `JSON_VALUE(${column}, '${node.path}')`;
3776
+ }
3777
+ });
3778
+ const procedures = new MssqlProcedureCompiler(composition.runtime);
3779
+ return {
3780
+ ...composition.dialect,
3781
+ compileProcedureCall: (ast) => procedures.compileProcedureCall(ast)
3782
+ };
3783
+ };
3784
+ var SqlServerDialect = class {
3785
+ impl = createSqlServerDialect();
3839
3786
  quoteIdentifier(id) {
3840
- return `[${id}]`;
3787
+ return this.impl.quoteIdentifier(id);
3841
3788
  }
3842
- compileJsonPath(node) {
3843
- const column = `${this.quoteIdentifier(node.column.table)}.${this.quoteIdentifier(node.column.name)}`;
3844
- return `JSON_VALUE(${column}, '${node.path}')`;
3789
+ supportsDmlReturningClause() {
3790
+ return this.impl.supportsDmlReturningClause();
3791
+ }
3792
+ compileSelect(ast) {
3793
+ return this.impl.compileSelect(ast);
3794
+ }
3795
+ compileInsert(ast) {
3796
+ return this.impl.compileInsert(ast);
3845
3797
  }
3846
- formatPlaceholder(index) {
3847
- return `@p${index}`;
3798
+ compileUpdate(ast) {
3799
+ return this.impl.compileUpdate(ast);
3800
+ }
3801
+ compileDelete(ast) {
3802
+ return this.impl.compileDelete(ast);
3848
3803
  }
3849
3804
  compileProcedureCall(ast) {
3850
- return this.procedureCompiler.compileProcedureCall(ast);
3805
+ return this.impl.compileProcedureCall(ast);
3851
3806
  }
3852
3807
  };
3853
3808
 
@@ -3858,59 +3813,33 @@ var DialectFactory = class {
3858
3813
  static ensureDefaults() {
3859
3814
  if (this.defaultsInitialized) return;
3860
3815
  this.defaultsInitialized = true;
3861
- if (!this.registry.has("postgres")) {
3862
- this.registry.set("postgres", () => new PostgresDialect());
3863
- }
3864
- if (!this.registry.has("mysql")) {
3865
- this.registry.set("mysql", () => new MySqlDialect());
3866
- }
3867
- if (!this.registry.has("sqlite")) {
3868
- this.registry.set("sqlite", () => new SqliteDialect());
3869
- }
3870
- if (!this.registry.has("mssql")) {
3871
- this.registry.set("mssql", () => new SqlServerDialect());
3872
- }
3816
+ if (!this.registry.has("postgres")) this.registry.set("postgres", createPostgresDialect);
3817
+ if (!this.registry.has("mysql")) this.registry.set("mysql", createMySqlDialect);
3818
+ if (!this.registry.has("sqlite")) this.registry.set("sqlite", createSqliteDialect);
3819
+ if (!this.registry.has("mssql")) this.registry.set("mssql", createSqlServerDialect);
3873
3820
  }
3874
- /**
3875
- * Register (or override) a dialect factory for a key.
3876
- *
3877
- * Implementations are structural: extending DialectBase/SqlDialectBase is
3878
- * optional. A composed object satisfying Dialect is a valid registration.
3879
- */
3821
+ /** Register or replace a structural dialect factory. */
3880
3822
  static register(key, factory) {
3881
3823
  this.registry.set(key, factory);
3882
3824
  }
3883
- /**
3884
- * Resolve a key into a Dialect instance.
3885
- * Throws if the key is not registered.
3886
- */
3825
+ /** Resolve a key into a new Dialect instance. */
3887
3826
  static create(key) {
3888
3827
  this.ensureDefaults();
3889
3828
  const factory = this.registry.get(key);
3890
3829
  if (!factory) {
3891
3830
  throw new Error(
3892
- `Dialect "${String(
3893
- key
3894
- )}" is not registered. Use DialectFactory.register(...) to register it.`
3831
+ `Dialect "${String(key)}" is not registered. Use DialectFactory.register(...) to register it.`
3895
3832
  );
3896
3833
  }
3897
3834
  return factory();
3898
3835
  }
3899
- /**
3900
- * Clear all registrations (mainly for tests).
3901
- * Built-ins will be re-registered lazily on the next create().
3902
- */
3836
+ /** Clear registrations; built-ins are restored lazily on the next create(). */
3903
3837
  static clear() {
3904
3838
  this.registry.clear();
3905
3839
  this.defaultsInitialized = false;
3906
3840
  }
3907
3841
  };
3908
- var resolveDialectInput = (dialect) => {
3909
- if (typeof dialect === "string") {
3910
- return DialectFactory.create(dialect);
3911
- }
3912
- return dialect;
3913
- };
3842
+ var resolveDialectInput = (dialect) => typeof dialect === "string" ? DialectFactory.create(dialect) : dialect;
3914
3843
 
3915
3844
  // src/core/ast/builders.ts
3916
3845
  var isColumnNode = (col2) => "type" in col2 && col2.type === "Column";
@@ -22311,7 +22240,6 @@ async function bulkUpsert(session, table, rows, options = {}) {
22311
22240
  DefaultMorphToReference,
22312
22241
  DefaultTypeStrategy,
22313
22242
  DeleteQueryBuilder,
22314
- DialectBase,
22315
22243
  DialectFactory,
22316
22244
  DomainEventBus,
22317
22245
  Email,
@@ -22357,7 +22285,6 @@ async function bulkUpsert(session, table, rows, options = {}) {
22357
22285
  RelationKinds,
22358
22286
  STANDARD_COLUMN_TYPES,
22359
22287
  SelectQueryBuilder,
22360
- SqlDialectBase,
22361
22288
  SqlServerDialect,
22362
22289
  SqliteDialect,
22363
22290
  SqliteReturningStrategy,
@@ -22439,6 +22366,7 @@ async function bulkUpsert(session, table, rows, options = {}) {
22439
22366
  columnToOpenApiSchema,
22440
22367
  columnTypeToOpenApiFormat,
22441
22368
  columnTypeToOpenApiType,
22369
+ composeSqlDialect,
22442
22370
  computePaginationMetadata,
22443
22371
  computeSchemaHash,
22444
22372
  concat,
@@ -22458,11 +22386,16 @@ async function bulkUpsert(session, table, rows, options = {}) {
22458
22386
  createExecutorFromQueryRunner,
22459
22387
  createMssqlCompilerSet,
22460
22388
  createMssqlExecutor,
22389
+ createMySqlDialect,
22461
22390
  createMysqlExecutor,
22462
22391
  createPooledExecutorFactory,
22392
+ createPostgresDialect,
22463
22393
  createPostgresExecutor,
22464
22394
  createQueryLoggingExecutor,
22465
22395
  createRef,
22396
+ createSqlDialect,
22397
+ createSqlServerDialect,
22398
+ createSqliteDialect,
22466
22399
  createSqliteExecutor,
22467
22400
  createTediousExecutor,
22468
22401
  createTediousMssqlClient,