metal-orm 1.1.25 → 1.1.27

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 (32) hide show
  1. package/dist/index.cjs +1151 -510
  2. package/dist/index.cjs.map +1 -1
  3. package/dist/index.d.cts +281 -248
  4. package/dist/index.d.ts +281 -248
  5. package/dist/index.js +1133 -508
  6. package/dist/index.js.map +1 -1
  7. package/package.json +1 -1
  8. package/src/core/ddl/dialects/index.ts +5 -6
  9. package/src/core/ddl/dialects/mssql-schema-dialect.ts +129 -126
  10. package/src/core/ddl/dialects/mysql-schema-dialect.ts +119 -111
  11. package/src/core/ddl/dialects/postgres-schema-dialect.ts +173 -164
  12. package/src/core/ddl/dialects/render-reference.test.ts +37 -57
  13. package/src/core/ddl/dialects/sqlite-schema-dialect.ts +110 -121
  14. package/src/core/ddl/schema-dialect-composer.ts +129 -0
  15. package/src/core/ddl/schema-dialect.ts +40 -27
  16. package/src/core/ddl/schema-diff.ts +119 -90
  17. package/src/core/dialect/abstract.ts +7 -229
  18. package/src/core/dialect/base/sql-dialect-composer.ts +294 -0
  19. package/src/core/dialect/base/standard-sql-services.ts +2 -6
  20. package/src/core/dialect/base/upsert-strategy.ts +1 -2
  21. package/src/core/dialect/dialect-factory.ts +17 -49
  22. package/src/core/dialect/mssql/index.ts +56 -27
  23. package/src/core/dialect/mysql/index.ts +69 -36
  24. package/src/core/dialect/postgres/index.ts +71 -43
  25. package/src/core/dialect/sqlite/index.ts +68 -38
  26. package/src/core/driver/mssql-driver.ts +6 -8
  27. package/src/core/driver/mysql-driver.ts +6 -8
  28. package/src/core/driver/postgres-driver.ts +6 -8
  29. package/src/core/driver/sqlite-driver.ts +6 -8
  30. package/src/index.ts +13 -1
  31. package/src/core/ddl/dialects/base-schema-dialect.ts +0 -96
  32. package/src/core/dialect/base/sql-dialect.ts +0 -217
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,
@@ -88,6 +87,7 @@ __export(index_exports, {
88
87
  KeyvCacheAdapter: () => KeyvCacheAdapter,
89
88
  Length: () => Length,
90
89
  Lower: () => Lower,
90
+ MSSqlSchemaDialect: () => MSSqlSchemaDialect,
91
91
  MemoryCacheAdapter: () => MemoryCacheAdapter,
92
92
  MorphMany: () => MorphMany,
93
93
  MorphOne: () => MorphOne,
@@ -100,6 +100,7 @@ __export(index_exports, {
100
100
  MssqlUpdateCompiler: () => MssqlUpdateCompiler,
101
101
  MySqlDialect: () => MySqlDialect,
102
102
  MySqlProcedureCompiler: () => MySqlProcedureCompiler,
103
+ MySqlSchemaDialect: () => MySqlSchemaDialect,
103
104
  MySqlUpsertStrategy: () => MySqlUpsertStrategy,
104
105
  NestedSetStrategy: () => NestedSetStrategy,
105
106
  NoReturningStrategy: () => NoReturningStrategy,
@@ -111,6 +112,7 @@ __export(index_exports, {
111
112
  PostgresDialect: () => PostgresDialect,
112
113
  PostgresProcedureCompiler: () => PostgresProcedureCompiler,
113
114
  PostgresReturningStrategy: () => PostgresReturningStrategy,
115
+ PostgresSchemaDialect: () => PostgresSchemaDialect,
114
116
  PostgresUpsertStrategy: () => PostgresUpsertStrategy,
115
117
  PrimaryKey: () => PrimaryKey,
116
118
  ProcedureCallBuilder: () => ProcedureCallBuilder,
@@ -118,9 +120,9 @@ __export(index_exports, {
118
120
  QueryCacheManager: () => QueryCacheManager,
119
121
  RedisCacheAdapter: () => RedisCacheAdapter,
120
122
  RelationKinds: () => RelationKinds,
123
+ SQLiteSchemaDialect: () => SQLiteSchemaDialect,
121
124
  STANDARD_COLUMN_TYPES: () => STANDARD_COLUMN_TYPES,
122
125
  SelectQueryBuilder: () => SelectQueryBuilder,
123
- SqlDialectBase: () => SqlDialectBase,
124
126
  SqlServerDialect: () => SqlServerDialect,
125
127
  SqliteDialect: () => SqliteDialect,
126
128
  SqliteReturningStrategy: () => SqliteReturningStrategy,
@@ -202,6 +204,8 @@ __export(index_exports, {
202
204
  columnToOpenApiSchema: () => columnToOpenApiSchema,
203
205
  columnTypeToOpenApiFormat: () => columnTypeToOpenApiFormat,
204
206
  columnTypeToOpenApiType: () => columnTypeToOpenApiType,
207
+ composeSchemaDialect: () => composeSchemaDialect,
208
+ composeSqlDialect: () => composeSqlDialect,
205
209
  computePaginationMetadata: () => computePaginationMetadata,
206
210
  computeSchemaHash: () => computeSchemaHash,
207
211
  concat: () => concat,
@@ -219,14 +223,26 @@ __export(index_exports, {
219
223
  createEntityFromRow: () => createEntityFromRow,
220
224
  createEntityProxy: () => createEntityProxy,
221
225
  createExecutorFromQueryRunner: () => createExecutorFromQueryRunner,
226
+ createLiteralFormatter: () => createLiteralFormatter,
222
227
  createMssqlCompilerSet: () => createMssqlCompilerSet,
223
228
  createMssqlExecutor: () => createMssqlExecutor,
229
+ createMssqlSchemaDialect: () => createMssqlSchemaDialect,
230
+ createMySqlDialect: () => createMySqlDialect,
231
+ createMySqlSchemaDialect: () => createMySqlSchemaDialect,
224
232
  createMysqlExecutor: () => createMysqlExecutor,
225
233
  createPooledExecutorFactory: () => createPooledExecutorFactory,
234
+ createPostgresDialect: () => createPostgresDialect,
226
235
  createPostgresExecutor: () => createPostgresExecutor,
236
+ createPostgresSchemaDialect: () => createPostgresSchemaDialect,
227
237
  createQueryLoggingExecutor: () => createQueryLoggingExecutor,
228
238
  createRef: () => createRef,
239
+ createSqlDialect: () => createSqlDialect,
240
+ createSqlServerDialect: () => createSqlServerDialect,
241
+ createSqliteDialect: () => createSqliteDialect,
229
242
  createSqliteExecutor: () => createSqliteExecutor,
243
+ createSqliteSchemaDialect: () => createSqliteSchemaDialect,
244
+ createStandardDropColumnCapability: () => createStandardDropColumnCapability,
245
+ createStandardDropTableCapability: () => createStandardDropTableCapability,
230
246
  createTediousExecutor: () => createTediousExecutor,
231
247
  createTediousMssqlClient: () => createTediousMssqlClient,
232
248
  createTreeManager: () => createTreeManager,
@@ -2004,159 +2020,6 @@ var SelectAstNormalizer = class {
2004
2020
  }
2005
2021
  };
2006
2022
 
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
2023
  // src/core/dialect/base/pagination-strategy.ts
2161
2024
  var StandardLimitOffsetPagination = class {
2162
2025
  /**
@@ -2181,19 +2044,19 @@ var NoReturningStrategy = class {
2181
2044
  if (!returning || returning.length === 0) return "";
2182
2045
  throw new Error("RETURNING is not supported by this dialect.");
2183
2046
  }
2184
- formatReturningColumns(returning, quoteIdentifier) {
2047
+ formatReturningColumns(returning, quoteIdentifier9) {
2185
2048
  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}`;
2049
+ const tablePart = column.table ? `${quoteIdentifier9(column.table)}.` : "";
2050
+ const aliasPart = column.alias ? ` AS ${quoteIdentifier9(column.alias)}` : "";
2051
+ return `${tablePart}${quoteIdentifier9(column.name)}${aliasPart}`;
2189
2052
  }).join(", ");
2190
2053
  }
2191
2054
  };
2192
2055
  var StandardReturningStrategy = class extends NoReturningStrategy {
2193
- compileReturning(returning, _ctx, quoteIdentifier) {
2056
+ compileReturning(returning, _ctx, quoteIdentifier9) {
2194
2057
  void _ctx;
2195
2058
  if (!returning || returning.length === 0) return "";
2196
- return ` RETURNING ${this.formatReturningColumns(returning, quoteIdentifier)}`;
2059
+ return ` RETURNING ${this.formatReturningColumns(returning, quoteIdentifier9)}`;
2197
2060
  }
2198
2061
  };
2199
2062
 
@@ -2324,13 +2187,13 @@ var CteCompiler = class {
2324
2187
  * @param stripTrailingSemicolon - Function to remove trailing semicolons from SQL.
2325
2188
  * @returns SQL WITH clause string (e.g., "WITH cte_name AS (...) ") or empty string if no CTEs.
2326
2189
  */
2327
- static compileCtes(ast, ctx, quoteIdentifier, compileSelectAst, normalizeSelectAst, stripTrailingSemicolon) {
2190
+ static compileCtes(ast, ctx, quoteIdentifier9, compileSelectAst, normalizeSelectAst, stripTrailingSemicolon) {
2328
2191
  if (!ast.ctes || ast.ctes.length === 0) return "";
2329
2192
  const hasRecursive = ast.ctes.some((cte) => cte.recursive);
2330
2193
  const prefix = hasRecursive ? "WITH RECURSIVE " : "WITH ";
2331
2194
  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(", ")})` : "";
2195
+ const name = quoteIdentifier9(cte.name);
2196
+ const cols = cte.columns && cte.columns.length ? `(${cte.columns.map((c) => quoteIdentifier9(c)).join(", ")})` : "";
2334
2197
  const query = stripTrailingSemicolon(compileSelectAst(normalizeSelectAst(cte.query), ctx));
2335
2198
  return `${name}${cols} AS (${query})`;
2336
2199
  }).join(", ");
@@ -2553,138 +2416,174 @@ var StandardDeleteCompiler = class {
2553
2416
  }
2554
2417
  };
2555
2418
 
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
2419
+ // src/core/dialect/base/sql-dialect-composer.ts
2420
+ var terminate = (sql) => {
2421
+ const trimmed = sql.trim();
2422
+ return trimmed.endsWith(";") ? trimmed : `${trimmed};`;
2423
+ };
2424
+ var composeSqlDialect = (config) => {
2425
+ const functionStrategy = config.functionStrategy ?? new StandardFunctionStrategy();
2426
+ const tableFunctionStrategy = config.tableFunctionStrategy ?? new StandardTableFunctionStrategy();
2427
+ const paginationStrategy = config.paginationStrategy ?? new StandardLimitOffsetPagination();
2428
+ const returningStrategy = config.returningStrategy ?? new NoReturningStrategy();
2429
+ const upsertStrategy = config.upsertStrategy ?? new NoUpsertStrategy();
2430
+ const selectAstNormalizer = new SelectAstNormalizer(
2431
+ (kind) => config.supportsSetOperation?.(kind) ?? true
2432
+ );
2433
+ let compilerSet;
2434
+ let expressionRegistry2;
2435
+ const createCompilerContext = () => {
2436
+ const params = [];
2437
+ let counter = 0;
2438
+ return {
2439
+ params,
2440
+ addParameter(value) {
2441
+ counter += 1;
2442
+ params.push(value);
2443
+ return config.formatPlaceholder?.(counter) ?? "?";
2444
+ }
2601
2445
  };
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
- }
2446
+ };
2447
+ const compileSelectAst = (ast, ctx) => compilerSet.select.compile(ast, ctx);
2448
+ const normalizeSelectAst = (ast) => selectAstNormalizer.normalize(ast);
2449
+ const compileSelectForExists = (ast, ctx) => {
2450
+ const normalized = normalizeSelectAst(ast);
2451
+ const full = compileSelectAst(normalized, ctx).trim().replace(/;$/, "");
2452
+ if (normalized.setOps && normalized.setOps.length > 0) {
2453
+ return `SELECT 1 FROM (${full}) AS _exists`;
2454
+ }
2455
+ const fromIndex = full.toUpperCase().indexOf(" FROM ");
2456
+ return fromIndex === -1 ? full : `SELECT 1${full.slice(fromIndex)}`;
2457
+ };
2458
+ const compileJsonPath = (node) => {
2459
+ if (!config.compileJsonPath) {
2460
+ throw new Error(`JSON Path not supported by dialect "${config.name}".`);
2461
+ }
2462
+ return config.compileJsonPath(node);
2463
+ };
2464
+ const compileFunctionOperand = (node, ctx) => {
2465
+ const compiledArgs = node.args.map((arg) => expressionRegistry2.compileOperand(arg, ctx));
2466
+ const renderer = functionStrategy.getRenderer(node.name);
2467
+ if (renderer) {
2468
+ return renderer({
2469
+ node,
2470
+ compiledArgs,
2471
+ compileOperand: (operand) => expressionRegistry2.compileOperand(operand, ctx)
2472
+ });
2473
+ }
2474
+ return `${node.name}(${compiledArgs.join(", ")})`;
2475
+ };
2476
+ expressionRegistry2 = new ExpressionCompilerRegistry({
2477
+ quoteIdentifier: config.quoteIdentifier,
2478
+ compileSelectAst,
2479
+ compileSelectForExists,
2480
+ compileJsonPath,
2481
+ compileFunctionOperand,
2482
+ describe: () => config.describe ?? config.name
2483
+ });
2484
+ const compileSetTarget = (column, table) => {
2485
+ if (config.compileSetTarget) return config.compileSetTarget(column, table);
2486
+ const columnTable = column.table ?? table.alias ?? table.name;
2487
+ const tableQualifier = table.alias && column.table === table.name ? table.alias : columnTable;
2488
+ return tableQualifier ? `${config.quoteIdentifier(tableQualifier)}.${config.quoteIdentifier(column.name)}` : config.quoteIdentifier(column.name);
2489
+ };
2490
+ let standardUpdate;
2491
+ const services = {
2492
+ getDialectName: () => config.name,
2493
+ getPaginationStrategy: () => paginationStrategy,
2494
+ getTableFunctionStrategy: () => tableFunctionStrategy,
2495
+ quoteIdentifier: config.quoteIdentifier,
2496
+ compileOperand: (node, ctx) => expressionRegistry2.compileOperand(node, ctx),
2497
+ compileExpression: (node, ctx) => expressionRegistry2.compileExpression(node, ctx),
2498
+ compileOrderingTerm: (term, ctx) => expressionRegistry2.compileOrderingTerm(term, ctx),
2499
+ normalizeSelectAst,
2500
+ compileSelectAst,
2501
+ compileReturning: (returning, ctx) => returningStrategy.compileReturning(returning, ctx, config.quoteIdentifier),
2502
+ compileUpsertClause: (ast, ctx) => upsertStrategy.compile(ast, ctx, {
2503
+ getDialectName: () => config.name,
2504
+ quoteIdentifier: config.quoteIdentifier,
2505
+ compileOperand: (node, compilerContext) => expressionRegistry2.compileOperand(node, compilerContext),
2506
+ compileExpression: (node, compilerContext) => expressionRegistry2.compileExpression(node, compilerContext),
2507
+ compileUpdateAssignments: (assignments, table, compilerContext) => standardUpdate.compileAssignments(assignments, table, compilerContext)
2508
+ }),
2509
+ compileSetTarget,
2510
+ renderOrderByNulls: (order) => config.renderOrderByNulls?.(order) ?? (order.nulls ? ` NULLS ${order.nulls}` : ""),
2511
+ renderOrderByCollation: (order) => config.renderOrderByCollation?.(order) ?? (order.collation ? ` COLLATE ${order.collation}` : "")
2512
+ };
2513
+ const sources = new StandardSqlSourceCompiler(services);
2514
+ const standardSelect = new StandardSelectCompiler(services, sources);
2515
+ const standardInsert = new StandardInsertCompiler(services, sources);
2516
+ standardUpdate = new StandardUpdateCompiler(services, sources);
2517
+ const standardDelete = new StandardDeleteCompiler(services, sources);
2518
+ const overrides = config.compilerFactory?.({ services, sources }) ?? {};
2519
+ compilerSet = {
2520
+ select: overrides.select ?? standardSelect,
2521
+ insert: overrides.insert ?? standardInsert,
2522
+ update: overrides.update ?? standardUpdate,
2523
+ delete: overrides.delete ?? standardDelete
2524
+ };
2525
+ const expressionApi = {
2526
+ registerExpressionCompiler(type, compiler) {
2527
+ expressionRegistry2.registerExpressionCompiler(type, compiler);
2528
+ },
2529
+ registerOperandCompiler(type, compiler) {
2530
+ expressionRegistry2.registerOperandCompiler(type, compiler);
2531
+ },
2532
+ compileExpression(node, ctx) {
2533
+ return expressionRegistry2.compileExpression(node, ctx);
2534
+ },
2535
+ compileOperand(node, ctx) {
2536
+ return expressionRegistry2.compileOperand(node, ctx);
2537
+ },
2538
+ compileOrderingTerm(term, ctx) {
2539
+ return expressionRegistry2.compileOrderingTerm(term, ctx);
2540
+ }
2541
+ };
2542
+ config.configureExpressions?.(expressionApi);
2543
+ const dialect = {
2544
+ quoteIdentifier: config.quoteIdentifier,
2545
+ supportsDmlReturningClause: () => config.supportsDmlReturning ?? false,
2546
+ compileSelect(ast) {
2547
+ const ctx = createCompilerContext();
2548
+ return {
2549
+ sql: terminate(compileSelectAst(normalizeSelectAst(ast), ctx)),
2550
+ params: [...ctx.params]
2551
+ };
2552
+ },
2553
+ compileInsert(ast) {
2554
+ const ctx = createCompilerContext();
2555
+ return {
2556
+ sql: terminate(compilerSet.insert.compile(ast, ctx)),
2557
+ params: [...ctx.params]
2558
+ };
2559
+ },
2560
+ compileUpdate(ast) {
2561
+ const ctx = createCompilerContext();
2562
+ return {
2563
+ sql: terminate(compilerSet.update.compile(ast, ctx)),
2564
+ params: [...ctx.params]
2565
+ };
2566
+ },
2567
+ compileDelete(ast) {
2568
+ const ctx = createCompilerContext();
2569
+ return {
2570
+ sql: terminate(compilerSet.delete.compile(ast, ctx)),
2571
+ params: [...ctx.params]
2572
+ };
2573
+ }
2574
+ };
2575
+ const runtime = {
2576
+ quoteIdentifier: config.quoteIdentifier,
2577
+ createCompilerContext,
2578
+ compileOperand: (node, ctx) => expressionRegistry2.compileOperand(node, ctx),
2579
+ compileExpression: (node, ctx) => expressionRegistry2.compileExpression(node, ctx),
2580
+ compileOrderingTerm: (term, ctx) => expressionRegistry2.compileOrderingTerm(term, ctx),
2581
+ normalizeSelectAst,
2582
+ compileSelectAst
2583
+ };
2584
+ return { dialect, runtime };
2687
2585
  };
2586
+ var createSqlDialect = (config) => composeSqlDialect(config).dialect;
2688
2587
 
2689
2588
  // src/core/dialect/postgres/functions.ts
2690
2589
  var PostgresFunctionStrategy = class extends StandardFunctionStrategy {
@@ -2847,15 +2746,15 @@ var PostgresTableFunctionStrategy = class extends StandardTableFunctionStrategy
2847
2746
  this.registerOverrides();
2848
2747
  }
2849
2748
  registerOverrides() {
2850
- this.add("ARRAY_UNNEST", ({ node, compiledArgs, quoteIdentifier }) => {
2749
+ this.add("ARRAY_UNNEST", ({ node, compiledArgs, quoteIdentifier: quoteIdentifier9 }) => {
2851
2750
  const lateral = node.lateral ?? true;
2852
2751
  const withOrd = node.withOrdinality ?? false;
2853
2752
  const base = `unnest(${compiledArgs.join(", ")})${withOrd ? " WITH ORDINALITY" : ""}`;
2854
2753
  if (node.columnAliases?.length && !node.alias) {
2855
2754
  throw new Error("tvf(ARRAY_UNNEST) with columnAliases requires an alias.");
2856
2755
  }
2857
- const alias = node.alias ? ` AS ${quoteIdentifier(node.alias)}` : "";
2858
- const cols = node.columnAliases?.length ? `(${node.columnAliases.map(quoteIdentifier).join(", ")})` : "";
2756
+ const alias = node.alias ? ` AS ${quoteIdentifier9(node.alias)}` : "";
2757
+ const cols = node.columnAliases?.length ? `(${node.columnAliases.map(quoteIdentifier9).join(", ")})` : "";
2859
2758
  return `${lateral ? "LATERAL " : ""}${base}${alias}${cols}`;
2860
2759
  });
2861
2760
  }
@@ -2920,52 +2819,68 @@ var PostgresUpsertStrategy = class {
2920
2819
  };
2921
2820
 
2922
2821
  // 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
- }
2822
+ var quoteIdentifier = (id) => `"${id}"`;
2823
+ var createPostgresDialect = () => {
2824
+ const composition = composeSqlDialect({
2825
+ name: "postgres",
2826
+ quoteIdentifier,
2827
+ formatPlaceholder: (index) => `$${index}`,
2828
+ functionStrategy: new PostgresFunctionStrategy(),
2829
+ tableFunctionStrategy: new PostgresTableFunctionStrategy(),
2830
+ returningStrategy: new PostgresReturningStrategy(),
2831
+ upsertStrategy: new PostgresUpsertStrategy(),
2832
+ supportsDmlReturning: true,
2833
+ compileSetTarget: (column, _table) => {
2834
+ void _table;
2835
+ return quoteIdentifier(column.name);
2836
+ },
2837
+ compileJsonPath(node) {
2838
+ const column = `${quoteIdentifier(node.column.table)}.${quoteIdentifier(node.column.name)}`;
2839
+ return `${column}->>'${node.path}'`;
2840
+ },
2841
+ configureExpressions(api) {
2842
+ api.registerExpressionCompiler("BitwiseExpression", (node, ctx) => {
2843
+ const left2 = api.compileOperand(node.left, ctx);
2844
+ const right2 = api.compileOperand(node.right, ctx);
2845
+ const operator = node.operator === "^" ? "#" : node.operator;
2846
+ return `${left2} ${operator} ${right2}`;
2847
+ });
2848
+ api.registerOperandCompiler("BitwiseExpression", (node, ctx) => {
2849
+ const left2 = api.compileOperand(node.left, ctx);
2850
+ const right2 = api.compileOperand(node.right, ctx);
2851
+ const operator = node.operator === "^" ? "#" : node.operator;
2852
+ return `(${left2} ${operator} ${right2})`;
2853
+ });
2854
+ }
2855
+ });
2856
+ const procedures = new PostgresProcedureCompiler(composition.runtime);
2857
+ return {
2858
+ ...composition.dialect,
2859
+ compileProcedureCall: (ast) => procedures.compileProcedureCall(ast)
2860
+ };
2861
+ };
2862
+ var PostgresDialect = class {
2863
+ impl = createPostgresDialect();
2952
2864
  quoteIdentifier(id) {
2953
- return `"${id}"`;
2865
+ return this.impl.quoteIdentifier(id);
2954
2866
  }
2955
- formatPlaceholder(index) {
2956
- return `$${index}`;
2867
+ supportsDmlReturningClause() {
2868
+ return this.impl.supportsDmlReturningClause();
2957
2869
  }
2958
- compileJsonPath(node) {
2959
- const column = `${this.quoteIdentifier(node.column.table)}.${this.quoteIdentifier(node.column.name)}`;
2960
- return `${column}->>'${node.path}'`;
2870
+ compileSelect(ast) {
2871
+ return this.impl.compileSelect(ast);
2961
2872
  }
2962
- /** PostgreSQL requires unqualified column names in SET clauses. */
2963
- compileSetTarget(column, _table) {
2964
- void _table;
2965
- return this.quoteIdentifier(column.name);
2873
+ compileInsert(ast) {
2874
+ return this.impl.compileInsert(ast);
2875
+ }
2876
+ compileUpdate(ast) {
2877
+ return this.impl.compileUpdate(ast);
2878
+ }
2879
+ compileDelete(ast) {
2880
+ return this.impl.compileDelete(ast);
2966
2881
  }
2967
2882
  compileProcedureCall(ast) {
2968
- return this.procedureCompiler.compileProcedureCall(ast);
2883
+ return this.impl.compileProcedureCall(ast);
2969
2884
  }
2970
2885
  };
2971
2886
 
@@ -3145,38 +3060,57 @@ var MySqlUpsertStrategy = class {
3145
3060
  };
3146
3061
 
3147
3062
  // 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
- }
3063
+ var quoteIdentifier2 = (id) => `\`${id}\``;
3064
+ var createMySqlDialect = () => {
3065
+ const composition = composeSqlDialect({
3066
+ name: "mysql",
3067
+ quoteIdentifier: quoteIdentifier2,
3068
+ functionStrategy: new MysqlFunctionStrategy(),
3069
+ upsertStrategy: new MySqlUpsertStrategy(),
3070
+ compileJsonPath(node) {
3071
+ const column = `${quoteIdentifier2(node.column.table)}.${quoteIdentifier2(node.column.name)}`;
3072
+ return `${column}->'${node.path}'`;
3073
+ },
3074
+ configureExpressions(api) {
3075
+ api.registerExpressionCompiler(
3076
+ "IsDistinctExpression",
3077
+ (node, ctx) => {
3078
+ const left2 = api.compileOperand(node.left, ctx);
3079
+ const right2 = api.compileOperand(node.right, ctx);
3080
+ const spaceship = `${left2} <=> ${right2}`;
3081
+ return node.operator === "IS NOT DISTINCT FROM" ? spaceship : `NOT (${spaceship})`;
3082
+ }
3083
+ );
3084
+ }
3085
+ });
3086
+ const procedures = new MySqlProcedureCompiler(composition.runtime);
3087
+ return {
3088
+ ...composition.dialect,
3089
+ compileProcedureCall: (ast) => procedures.compileProcedureCall(ast)
3090
+ };
3091
+ };
3092
+ var MySqlDialect = class {
3093
+ impl = createMySqlDialect();
3171
3094
  quoteIdentifier(id) {
3172
- return `\`${id}\``;
3095
+ return this.impl.quoteIdentifier(id);
3173
3096
  }
3174
- compileJsonPath(node) {
3175
- const column = `${this.quoteIdentifier(node.column.table)}.${this.quoteIdentifier(node.column.name)}`;
3176
- return `${column}->'${node.path}'`;
3097
+ supportsDmlReturningClause() {
3098
+ return this.impl.supportsDmlReturningClause();
3099
+ }
3100
+ compileSelect(ast) {
3101
+ return this.impl.compileSelect(ast);
3102
+ }
3103
+ compileInsert(ast) {
3104
+ return this.impl.compileInsert(ast);
3105
+ }
3106
+ compileUpdate(ast) {
3107
+ return this.impl.compileUpdate(ast);
3108
+ }
3109
+ compileDelete(ast) {
3110
+ return this.impl.compileDelete(ast);
3177
3111
  }
3178
3112
  compileProcedureCall(ast) {
3179
- return this.procedureCompiler.compileProcedureCall(ast);
3113
+ return this.impl.compileProcedureCall(ast);
3180
3114
  }
3181
3115
  };
3182
3116
 
@@ -3319,15 +3253,15 @@ var SqliteFunctionStrategy = class extends StandardFunctionStrategy {
3319
3253
 
3320
3254
  // src/core/dialect/sqlite/returning.ts
3321
3255
  var SqliteReturningStrategy = class {
3322
- compileReturning(returning, _ctx, quoteIdentifier) {
3256
+ compileReturning(returning, _ctx, quoteIdentifier9) {
3323
3257
  void _ctx;
3324
3258
  if (!returning || returning.length === 0) return "";
3325
- return ` RETURNING ${this.formatReturningColumns(returning, quoteIdentifier)}`;
3259
+ return ` RETURNING ${this.formatReturningColumns(returning, quoteIdentifier9)}`;
3326
3260
  }
3327
- formatReturningColumns(returning, quoteIdentifier) {
3261
+ formatReturningColumns(returning, quoteIdentifier9) {
3328
3262
  return returning.map((column) => {
3329
- const alias = column.alias ? ` AS ${quoteIdentifier(column.alias)}` : "";
3330
- return `${quoteIdentifier(column.name)}${alias}`;
3263
+ const alias = column.alias ? ` AS ${quoteIdentifier9(column.alias)}` : "";
3264
+ return `${quoteIdentifier9(column.name)}${alias}`;
3331
3265
  }).join(", ");
3332
3266
  }
3333
3267
  };
@@ -3358,42 +3292,60 @@ var SqliteUpsertStrategy = class {
3358
3292
  };
3359
3293
 
3360
3294
  // 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);
3295
+ var quoteIdentifier3 = (id) => `"${id}"`;
3296
+ var createSqliteDialect = () => composeSqlDialect({
3297
+ name: "sqlite",
3298
+ quoteIdentifier: quoteIdentifier3,
3299
+ functionStrategy: new SqliteFunctionStrategy(),
3300
+ returningStrategy: new SqliteReturningStrategy(),
3301
+ upsertStrategy: new SqliteUpsertStrategy(),
3302
+ supportsDmlReturning: true,
3303
+ compileSetTarget: (column, _table) => {
3304
+ void _table;
3305
+ return quoteIdentifier3(column.name);
3306
+ },
3307
+ compileJsonPath(node) {
3308
+ const column = `${quoteIdentifier3(node.column.table)}.${quoteIdentifier3(node.column.name)}`;
3309
+ return `json_extract(${column}, '${node.path}')`;
3310
+ },
3311
+ configureExpressions(api) {
3312
+ api.registerExpressionCompiler("BitwiseExpression", (node, ctx) => {
3313
+ const left2 = api.compileOperand(node.left, ctx);
3314
+ const right2 = api.compileOperand(node.right, ctx);
3373
3315
  if (node.operator === "^") {
3374
3316
  return `(${left2} | ${right2}) & ~(${left2} & ${right2})`;
3375
3317
  }
3376
3318
  return `${left2} ${node.operator} ${right2}`;
3377
3319
  });
3378
- this.registerOperandCompiler("BitwiseExpression", (node, ctx) => {
3379
- const left2 = this.compileOperand(node.left, ctx);
3380
- const right2 = this.compileOperand(node.right, ctx);
3320
+ api.registerOperandCompiler("BitwiseExpression", (node, ctx) => {
3321
+ const left2 = api.compileOperand(node.left, ctx);
3322
+ const right2 = api.compileOperand(node.right, ctx);
3381
3323
  if (node.operator === "^") {
3382
3324
  return `((${left2} | ${right2}) & ~(${left2} & ${right2}))`;
3383
3325
  }
3384
3326
  return `(${left2} ${node.operator} ${right2})`;
3385
3327
  });
3386
3328
  }
3329
+ }).dialect;
3330
+ var SqliteDialect = class {
3331
+ impl = createSqliteDialect();
3387
3332
  quoteIdentifier(id) {
3388
- return `"${id}"`;
3333
+ return this.impl.quoteIdentifier(id);
3389
3334
  }
3390
- compileJsonPath(node) {
3391
- const column = `${this.quoteIdentifier(node.column.table)}.${this.quoteIdentifier(node.column.name)}`;
3392
- return `json_extract(${column}, '${node.path}')`;
3335
+ supportsDmlReturningClause() {
3336
+ return this.impl.supportsDmlReturningClause();
3393
3337
  }
3394
- compileQualifiedColumn(column, _table) {
3395
- void _table;
3396
- return this.quoteIdentifier(column.name);
3338
+ compileSelect(ast) {
3339
+ return this.impl.compileSelect(ast);
3340
+ }
3341
+ compileInsert(ast) {
3342
+ return this.impl.compileInsert(ast);
3343
+ }
3344
+ compileUpdate(ast) {
3345
+ return this.impl.compileUpdate(ast);
3346
+ }
3347
+ compileDelete(ast) {
3348
+ return this.impl.compileDelete(ast);
3397
3349
  }
3398
3350
  };
3399
3351
 
@@ -3523,22 +3475,22 @@ var MssqlFunctionStrategy = class extends StandardFunctionStrategy {
3523
3475
 
3524
3476
  // src/core/dialect/mssql/output.ts
3525
3477
  var MssqlOutputStrategy = class {
3526
- compileReturning(returning, _ctx, quoteIdentifier) {
3478
+ compileReturning(returning, _ctx, quoteIdentifier9) {
3527
3479
  void _ctx;
3528
- return this.compileOutput(returning, "inserted", quoteIdentifier);
3480
+ return this.compileOutput(returning, "inserted", quoteIdentifier9);
3529
3481
  }
3530
- compileOutput(returning, prefix, quoteIdentifier) {
3482
+ compileOutput(returning, prefix, quoteIdentifier9) {
3531
3483
  if (!returning || returning.length === 0) return "";
3532
3484
  const columns = returning.map((column) => {
3533
- const alias = column.alias ? ` AS ${quoteIdentifier(column.alias)}` : "";
3534
- return `${prefix}.${quoteIdentifier(column.name)}${alias}`;
3485
+ const alias = column.alias ? ` AS ${quoteIdentifier9(column.alias)}` : "";
3486
+ return `${prefix}.${quoteIdentifier9(column.name)}${alias}`;
3535
3487
  }).join(", ");
3536
3488
  return ` OUTPUT ${columns}`;
3537
3489
  }
3538
- formatReturningColumns(returning, quoteIdentifier) {
3490
+ formatReturningColumns(returning, quoteIdentifier9) {
3539
3491
  return returning.map((column) => {
3540
- const alias = column.alias ? ` AS ${quoteIdentifier(column.alias)}` : "";
3541
- return `${quoteIdentifier(column.name)}${alias}`;
3492
+ const alias = column.alias ? ` AS ${quoteIdentifier9(column.alias)}` : "";
3493
+ return `${quoteIdentifier9(column.name)}${alias}`;
3542
3494
  }).join(", ");
3543
3495
  }
3544
3496
  };
@@ -3820,34 +3772,49 @@ var MssqlProcedureCompiler = class {
3820
3772
  };
3821
3773
 
3822
3774
  // 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
- }
3775
+ var quoteIdentifier4 = (id) => `[${id}]`;
3776
+ var createSqlServerDialect = () => {
3777
+ const composition = composeSqlDialect({
3778
+ name: "mssql",
3779
+ quoteIdentifier: quoteIdentifier4,
3780
+ formatPlaceholder: (index) => `@p${index}`,
3781
+ functionStrategy: new MssqlFunctionStrategy(),
3782
+ returningStrategy: new MssqlOutputStrategy(),
3783
+ compilerFactory: createMssqlCompilerSet,
3784
+ supportsDmlReturning: true,
3785
+ compileJsonPath(node) {
3786
+ const column = `${quoteIdentifier4(node.column.table)}.${quoteIdentifier4(node.column.name)}`;
3787
+ return `JSON_VALUE(${column}, '${node.path}')`;
3788
+ }
3789
+ });
3790
+ const procedures = new MssqlProcedureCompiler(composition.runtime);
3791
+ return {
3792
+ ...composition.dialect,
3793
+ compileProcedureCall: (ast) => procedures.compileProcedureCall(ast)
3794
+ };
3795
+ };
3796
+ var SqlServerDialect = class {
3797
+ impl = createSqlServerDialect();
3839
3798
  quoteIdentifier(id) {
3840
- return `[${id}]`;
3799
+ return this.impl.quoteIdentifier(id);
3841
3800
  }
3842
- compileJsonPath(node) {
3843
- const column = `${this.quoteIdentifier(node.column.table)}.${this.quoteIdentifier(node.column.name)}`;
3844
- return `JSON_VALUE(${column}, '${node.path}')`;
3801
+ supportsDmlReturningClause() {
3802
+ return this.impl.supportsDmlReturningClause();
3845
3803
  }
3846
- formatPlaceholder(index) {
3847
- return `@p${index}`;
3804
+ compileSelect(ast) {
3805
+ return this.impl.compileSelect(ast);
3806
+ }
3807
+ compileInsert(ast) {
3808
+ return this.impl.compileInsert(ast);
3809
+ }
3810
+ compileUpdate(ast) {
3811
+ return this.impl.compileUpdate(ast);
3812
+ }
3813
+ compileDelete(ast) {
3814
+ return this.impl.compileDelete(ast);
3848
3815
  }
3849
3816
  compileProcedureCall(ast) {
3850
- return this.procedureCompiler.compileProcedureCall(ast);
3817
+ return this.impl.compileProcedureCall(ast);
3851
3818
  }
3852
3819
  };
3853
3820
 
@@ -3858,59 +3825,33 @@ var DialectFactory = class {
3858
3825
  static ensureDefaults() {
3859
3826
  if (this.defaultsInitialized) return;
3860
3827
  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
- }
3828
+ if (!this.registry.has("postgres")) this.registry.set("postgres", createPostgresDialect);
3829
+ if (!this.registry.has("mysql")) this.registry.set("mysql", createMySqlDialect);
3830
+ if (!this.registry.has("sqlite")) this.registry.set("sqlite", createSqliteDialect);
3831
+ if (!this.registry.has("mssql")) this.registry.set("mssql", createSqlServerDialect);
3873
3832
  }
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
- */
3833
+ /** Register or replace a structural dialect factory. */
3880
3834
  static register(key, factory) {
3881
3835
  this.registry.set(key, factory);
3882
3836
  }
3883
- /**
3884
- * Resolve a key into a Dialect instance.
3885
- * Throws if the key is not registered.
3886
- */
3837
+ /** Resolve a key into a new Dialect instance. */
3887
3838
  static create(key) {
3888
3839
  this.ensureDefaults();
3889
3840
  const factory = this.registry.get(key);
3890
3841
  if (!factory) {
3891
3842
  throw new Error(
3892
- `Dialect "${String(
3893
- key
3894
- )}" is not registered. Use DialectFactory.register(...) to register it.`
3843
+ `Dialect "${String(key)}" is not registered. Use DialectFactory.register(...) to register it.`
3895
3844
  );
3896
3845
  }
3897
3846
  return factory();
3898
3847
  }
3899
- /**
3900
- * Clear all registrations (mainly for tests).
3901
- * Built-ins will be re-registered lazily on the next create().
3902
- */
3848
+ /** Clear registrations; built-ins are restored lazily on the next create(). */
3903
3849
  static clear() {
3904
3850
  this.registry.clear();
3905
3851
  this.defaultsInitialized = false;
3906
3852
  }
3907
3853
  };
3908
- var resolveDialectInput = (dialect) => {
3909
- if (typeof dialect === "string") {
3910
- return DialectFactory.create(dialect);
3911
- }
3912
- return dialect;
3913
- };
3854
+ var resolveDialectInput = (dialect) => typeof dialect === "string" ? DialectFactory.create(dialect) : dialect;
3914
3855
 
3915
3856
  // src/core/ast/builders.ts
3916
3857
  var isColumnNode = (col2) => "type" in col2 && col2.type === "Column";
@@ -11620,6 +11561,59 @@ var deleteFrom = (target) => {
11620
11561
  };
11621
11562
 
11622
11563
  // src/core/ddl/sql-writing.ts
11564
+ var escapeSqlString = (value) => value.replace(/'/g, "''");
11565
+ var isRawDefault = (value) => typeof value === "object" && value !== null && "raw" in value && typeof value.raw === "string";
11566
+ var createLiteralFormatter = (options = {}) => {
11567
+ const {
11568
+ nullLiteral = "NULL",
11569
+ booleanTrue = "TRUE",
11570
+ booleanFalse = "FALSE",
11571
+ numberFormatter = (value) => Number.isFinite(value) ? String(value) : nullLiteral,
11572
+ dateFormatter = (value) => `'${escapeSqlString(value.toISOString())}'`,
11573
+ stringWrapper = (escaped) => `'${escaped}'`,
11574
+ jsonWrapper = (escaped) => `'${escaped}'`
11575
+ } = options;
11576
+ const wrapString = stringWrapper;
11577
+ const wrapJson = jsonWrapper;
11578
+ const format = (value) => {
11579
+ if (isRawDefault(value)) return value.raw;
11580
+ if (value === null) return nullLiteral;
11581
+ if (typeof value === "number") {
11582
+ return numberFormatter(value);
11583
+ }
11584
+ if (typeof value === "boolean") {
11585
+ return value ? booleanTrue : booleanFalse;
11586
+ }
11587
+ if (value instanceof Date) {
11588
+ return dateFormatter(value);
11589
+ }
11590
+ if (typeof value === "string") {
11591
+ return wrapString(escapeSqlString(value));
11592
+ }
11593
+ return wrapJson(escapeSqlString(JSON.stringify(value)));
11594
+ };
11595
+ return {
11596
+ formatLiteral: format
11597
+ };
11598
+ };
11599
+ var formatLiteral = (formatter, value) => formatter.formatLiteral(value);
11600
+ var quoteQualified = (quoter, identifier) => {
11601
+ const parts = identifier.split(".");
11602
+ return parts.map((part) => quoter.quoteIdentifier(part)).join(".");
11603
+ };
11604
+ var renderIndexColumns = (quoter, columns) => columns.map((col2) => {
11605
+ if (typeof col2 === "string") {
11606
+ return quoter.quoteIdentifier(col2);
11607
+ }
11608
+ const parts = [quoter.quoteIdentifier(col2.column)];
11609
+ if (col2.order) {
11610
+ parts.push(col2.order);
11611
+ }
11612
+ if (col2.nulls) {
11613
+ parts.push(`NULLS ${col2.nulls}`);
11614
+ }
11615
+ return parts.join(" ");
11616
+ }).join(", ");
11623
11617
  var resolvePrimaryKey = (table) => {
11624
11618
  if (Array.isArray(table.primaryKey) && table.primaryKey.length > 0) {
11625
11619
  return table.primaryKey;
@@ -11756,13 +11750,11 @@ var deriveIndexName = (table, index) => {
11756
11750
  var tableKey = (name, schema) => schema ? `${schema}.${name}` : name;
11757
11751
  var mapTables = (schema) => {
11758
11752
  const map = /* @__PURE__ */ new Map();
11759
- for (const table of schema.tables) {
11760
- map.set(tableKey(table.name, table.schema), table);
11761
- }
11753
+ for (const table of schema.tables) map.set(tableKey(table.name, table.schema), table);
11762
11754
  return map;
11763
11755
  };
11764
- var buildAddColumnSql = (table, colName, dialect) => {
11765
- const column = table.columns[colName];
11756
+ var buildAddColumnSql = (table, columnName, dialect) => {
11757
+ const column = table.columns[columnName];
11766
11758
  const rendered = renderColumnDefinition(table, column, dialect);
11767
11759
  return `ALTER TABLE ${dialect.formatTableName(table)} ADD ${rendered.sql};`;
11768
11760
  };
@@ -11783,6 +11775,7 @@ var diffColumn = (expected, actual, dialect) => {
11783
11775
  autoIncrementChanged: !!expected.autoIncrement !== !!actual.autoIncrement
11784
11776
  };
11785
11777
  };
11778
+ var unsupportedMutationWarning = (dialect, operation, target) => `Dialect "${dialect.name}" does not provide the ${operation} capability for ${target}; manual migration is required.`;
11786
11779
  var diffSchema = (expectedTables, actualSchema, dialect, options = {}) => {
11787
11780
  const allowDestructive = options.allowDestructive ?? false;
11788
11781
  const plan = { changes: [], warnings: [] };
@@ -11801,87 +11794,121 @@ var diffSchema = (expectedTables, actualSchema, dialect, options = {}) => {
11801
11794
  });
11802
11795
  continue;
11803
11796
  }
11804
- const actualCols = new Map(actual.columns.map((c) => [c.name, c]));
11805
- for (const colName of Object.keys(table.columns)) {
11806
- if (!actualCols.has(colName)) {
11797
+ const actualColumns = new Map(actual.columns.map((column) => [column.name, column]));
11798
+ for (const columnName of Object.keys(table.columns)) {
11799
+ if (!actualColumns.has(columnName)) {
11807
11800
  plan.changes.push({
11808
11801
  kind: "addColumn",
11809
11802
  table: key,
11810
- description: `Add column ${colName} to ${key}`,
11811
- statements: [buildAddColumnSql(table, colName, dialect)],
11803
+ description: `Add column ${columnName} to ${key}`,
11804
+ statements: [buildAddColumnSql(table, columnName, dialect)],
11812
11805
  safe: true
11813
11806
  });
11814
- } else {
11815
- const expectedCol = table.columns[colName];
11816
- const actualCol = actualCols.get(colName);
11817
- const colDiff = diffColumn(expectedCol, actualCol, dialect);
11818
- const shouldAlter = colDiff.typeChanged || colDiff.nullabilityChanged || colDiff.defaultChanged || colDiff.autoIncrementChanged;
11819
- if (shouldAlter) {
11820
- const statements = dialect.alterColumnSql?.(table, expectedCol, actualCol, colDiff) ?? [];
11807
+ continue;
11808
+ }
11809
+ const expectedColumn = table.columns[columnName];
11810
+ const actualColumn = actualColumns.get(columnName);
11811
+ const columnDiff = diffColumn(expectedColumn, actualColumn, dialect);
11812
+ const shouldAlter = columnDiff.typeChanged || columnDiff.nullabilityChanged || columnDiff.defaultChanged || columnDiff.autoIncrementChanged;
11813
+ if (shouldAlter) {
11814
+ const capability = dialect.mutations.alterColumn;
11815
+ if (capability) {
11816
+ const statements = capability.compile(table, expectedColumn, actualColumn, columnDiff);
11821
11817
  if (statements.length > 0) {
11822
11818
  plan.changes.push({
11823
11819
  kind: "alterColumn",
11824
11820
  table: key,
11825
- description: `Alter column ${colName} on ${key}`,
11821
+ description: `Alter column ${columnName} on ${key}`,
11826
11822
  statements,
11827
11823
  safe: true
11828
11824
  });
11829
11825
  }
11830
- const warning = dialect.warnAlterColumn?.(table, expectedCol, actualCol, colDiff);
11826
+ const warning = capability.warning?.(table, expectedColumn, actualColumn, columnDiff);
11831
11827
  if (warning) plan.warnings.push(warning);
11828
+ } else {
11829
+ plan.warnings.push(
11830
+ unsupportedMutationWarning(dialect, "ALTER COLUMN", `${key}.${columnName}`)
11831
+ );
11832
11832
  }
11833
11833
  }
11834
11834
  }
11835
- for (const colName of actualCols.keys()) {
11836
- if (!table.columns[colName]) {
11837
- plan.changes.push({
11838
- kind: "dropColumn",
11839
- table: key,
11840
- description: `Drop column ${colName} from ${key}`,
11841
- statements: allowDestructive ? dialect.dropColumnSql(actual, colName) : [],
11842
- safe: false
11843
- });
11844
- const warning = dialect.warnDropColumn?.(actual, colName);
11835
+ for (const columnName of actualColumns.keys()) {
11836
+ if (table.columns[columnName]) continue;
11837
+ const capability = dialect.mutations.dropColumn;
11838
+ const statements = allowDestructive && capability ? capability.compile(actual, columnName) : [];
11839
+ plan.changes.push({
11840
+ kind: "dropColumn",
11841
+ table: key,
11842
+ description: `Drop column ${columnName} from ${key}`,
11843
+ statements,
11844
+ safe: false
11845
+ });
11846
+ if (!capability) {
11847
+ plan.warnings.push(
11848
+ unsupportedMutationWarning(dialect, "DROP COLUMN", `${key}.${columnName}`)
11849
+ );
11850
+ } else {
11851
+ const warning = capability.warning?.(actual, columnName);
11845
11852
  if (warning) plan.warnings.push(warning);
11846
11853
  }
11847
11854
  }
11848
11855
  const expectedIndexes = table.indexes ?? [];
11849
11856
  const actualIndexes = actual.indexes ?? [];
11850
- const actualIndexMap = new Map(actualIndexes.map((idx) => [idx.name, idx]));
11851
- for (const idx of expectedIndexes) {
11852
- const name = idx.name || deriveIndexName(table, idx);
11857
+ const actualIndexMap = new Map(actualIndexes.map((index) => [index.name, index]));
11858
+ for (const index of expectedIndexes) {
11859
+ const name = index.name || deriveIndexName(table, index);
11853
11860
  if (!actualIndexMap.has(name)) {
11854
11861
  plan.changes.push({
11855
11862
  kind: "addIndex",
11856
11863
  table: key,
11857
11864
  description: `Create index ${name} on ${key}`,
11858
- statements: [dialect.renderIndex(table, { ...idx, name })],
11865
+ statements: [dialect.renderIndex(table, { ...index, name })],
11859
11866
  safe: true
11860
11867
  });
11861
11868
  }
11862
11869
  }
11863
- for (const idx of actualIndexes) {
11864
- if (idx.name && !expectedIndexes.find((expected) => (expected.name || deriveIndexName(table, expected)) === idx.name)) {
11865
- plan.changes.push({
11866
- kind: "dropIndex",
11867
- table: key,
11868
- description: `Drop index ${idx.name} on ${key}`,
11869
- statements: allowDestructive ? dialect.dropIndexSql(actual, idx.name) : [],
11870
- safe: false
11871
- });
11870
+ for (const index of actualIndexes) {
11871
+ if (!index.name) continue;
11872
+ const expected = expectedIndexes.find(
11873
+ (candidate) => (candidate.name || deriveIndexName(table, candidate)) === index.name
11874
+ );
11875
+ if (expected) continue;
11876
+ const capability = dialect.mutations.dropIndex;
11877
+ const statements = allowDestructive && capability ? capability.compile(actual, index.name) : [];
11878
+ plan.changes.push({
11879
+ kind: "dropIndex",
11880
+ table: key,
11881
+ description: `Drop index ${index.name} on ${key}`,
11882
+ statements,
11883
+ safe: false
11884
+ });
11885
+ if (!capability) {
11886
+ plan.warnings.push(
11887
+ unsupportedMutationWarning(dialect, "DROP INDEX", `${key}.${index.name}`)
11888
+ );
11889
+ } else {
11890
+ const warning = capability.warning?.(actual, index.name);
11891
+ if (warning) plan.warnings.push(warning);
11872
11892
  }
11873
11893
  }
11874
11894
  }
11875
11895
  for (const actual of actualSchema.tables) {
11876
11896
  const key = tableKey(actual.name, actual.schema);
11877
- if (!expectedTables.find((t) => tableKey(t.name, t.schema) === key)) {
11878
- plan.changes.push({
11879
- kind: "dropTable",
11880
- table: key,
11881
- description: `Drop table ${key}`,
11882
- statements: allowDestructive ? dialect.dropTableSql(actual) : [],
11883
- safe: false
11884
- });
11897
+ if (expectedTables.find((table) => tableKey(table.name, table.schema) === key)) continue;
11898
+ const capability = dialect.mutations.dropTable;
11899
+ const statements = allowDestructive && capability ? capability.compile(actual) : [];
11900
+ plan.changes.push({
11901
+ kind: "dropTable",
11902
+ table: key,
11903
+ description: `Drop table ${key}`,
11904
+ statements,
11905
+ safe: false
11906
+ });
11907
+ if (!capability) {
11908
+ plan.warnings.push(unsupportedMutationWarning(dialect, "DROP TABLE", key));
11909
+ } else {
11910
+ const warning = capability.warning?.(actual);
11911
+ if (warning) plan.warnings.push(warning);
11885
11912
  }
11886
11913
  }
11887
11914
  return plan;
@@ -13827,6 +13854,604 @@ var introspectSchema = async (executor, dialect, options = {}) => {
13827
13854
  return handler.introspect(ctx, options);
13828
13855
  };
13829
13856
 
13857
+ // src/core/ddl/schema-dialect-composer.ts
13858
+ var composeSchemaDialect = (config) => {
13859
+ const quoteIdentifier9 = (id) => config.quoteIdentifier(id);
13860
+ const formatTableName = (table) => table.schema ? `${quoteIdentifier9(table.schema)}.${quoteIdentifier9(table.name)}` : quoteIdentifier9(table.name);
13861
+ let services;
13862
+ const renderDefault = (value, column) => config.renderDefault?.(value, column, services) ?? formatLiteral(config.literalFormatter, value);
13863
+ services = {
13864
+ name: config.name,
13865
+ quoteIdentifier: quoteIdentifier9,
13866
+ formatTableName,
13867
+ renderDefault
13868
+ };
13869
+ const mutations = config.mutations?.(services) ?? {};
13870
+ return {
13871
+ name: config.name,
13872
+ mutations,
13873
+ quoteIdentifier: quoteIdentifier9,
13874
+ formatTableName,
13875
+ renderColumnType: (column) => config.renderColumnType(column, services),
13876
+ renderDefault,
13877
+ renderAutoIncrement: (column, table) => config.renderAutoIncrement(column, table, services),
13878
+ renderReference(ref, table) {
13879
+ const parts = [
13880
+ "REFERENCES",
13881
+ quoteQualified({ quoteIdentifier: quoteIdentifier9 }, ref.table),
13882
+ `(${quoteIdentifier9(ref.column)})`
13883
+ ];
13884
+ if (ref.onDelete) parts.push("ON DELETE", ref.onDelete);
13885
+ if (ref.onUpdate) parts.push("ON UPDATE", ref.onUpdate);
13886
+ const suffix = config.renderReferenceSuffix?.(ref, table, services);
13887
+ if (suffix) parts.push(suffix);
13888
+ return parts.join(" ");
13889
+ },
13890
+ renderIndex: (table, index) => config.renderIndex(table, index, services),
13891
+ renderTableOptions: (table) => config.renderTableOptions?.(table, services),
13892
+ supportsPartialIndexes: () => config.supportsPartialIndexes ?? false,
13893
+ preferInlinePkAutoincrement: (column, table, pk) => config.preferInlinePkAutoincrement?.(column, table, pk, services) ?? false
13894
+ };
13895
+ };
13896
+ var createStandardDropTableCapability = (services) => ({
13897
+ compile: (table) => [`DROP TABLE IF EXISTS ${services.formatTableName(table)};`]
13898
+ });
13899
+ var createStandardDropColumnCapability = (services) => ({
13900
+ compile: (table, column) => [
13901
+ `ALTER TABLE ${services.formatTableName(table)} DROP COLUMN ${services.quoteIdentifier(column)};`
13902
+ ]
13903
+ });
13904
+
13905
+ // src/core/ddl/dialects/postgres-schema-dialect.ts
13906
+ var quoteIdentifier5 = (id) => `"${id}"`;
13907
+ var literalFormatter = createLiteralFormatter();
13908
+ var renderPostgresColumnType = (column, services) => {
13909
+ const override = column.dialectTypes?.[services.name] ?? column.dialectTypes?.default;
13910
+ if (override) return renderTypeWithArgs(override, column.args);
13911
+ const type = normalizeColumnType(column.type);
13912
+ switch (type) {
13913
+ case "int":
13914
+ case "integer":
13915
+ return "integer";
13916
+ case "bigint":
13917
+ return "bigint";
13918
+ case "uuid":
13919
+ return "uuid";
13920
+ case "boolean":
13921
+ return "boolean";
13922
+ case "json":
13923
+ return "jsonb";
13924
+ case "decimal":
13925
+ return column.args?.length ? `numeric(${column.args[0]}, ${column.args[1] ?? 0})` : "numeric";
13926
+ case "float":
13927
+ case "double":
13928
+ return "double precision";
13929
+ case "timestamptz":
13930
+ return "timestamptz";
13931
+ case "timestamp":
13932
+ return "timestamp";
13933
+ case "date":
13934
+ return "date";
13935
+ case "datetime":
13936
+ return "timestamp";
13937
+ case "varchar":
13938
+ return column.args?.length ? `varchar(${column.args[0]})` : "varchar";
13939
+ case "text":
13940
+ return "text";
13941
+ case "enum":
13942
+ return "text";
13943
+ case "binary":
13944
+ case "varbinary":
13945
+ case "blob":
13946
+ case "bytea":
13947
+ return "bytea";
13948
+ case "vector":
13949
+ return column.vectorOptions?.elementType === "float16" ? `halfvec(${column.vectorOptions.dimensions})` : column.args?.length ? `vector(${column.args[0]})` : "vector";
13950
+ case "halfvec":
13951
+ return column.args?.length ? `halfvec(${column.args[0]})` : "halfvec";
13952
+ default:
13953
+ return renderTypeWithArgs(String(type).toLowerCase(), column.args);
13954
+ }
13955
+ };
13956
+ var renderPostgresIndex = (table, index, services) => {
13957
+ const name = index.name || deriveIndexName(table, index);
13958
+ let columns = renderIndexColumns(services, index.columns);
13959
+ if (index.ops) columns = `${columns} ${index.ops}`;
13960
+ const unique = index.unique ? "UNIQUE " : "";
13961
+ const using = index.using ? ` USING ${index.using}` : "";
13962
+ let withClause = "";
13963
+ if (index.with) {
13964
+ if (typeof index.with === "string") {
13965
+ withClause = ` WITH (${index.with})`;
13966
+ } else {
13967
+ const params = Object.entries(index.with).map(([key, value]) => `${key} = ${value}`).join(", ");
13968
+ withClause = ` WITH (${params})`;
13969
+ }
13970
+ }
13971
+ const where = index.where ? ` WHERE ${index.where}` : "";
13972
+ return `CREATE ${unique}INDEX IF NOT EXISTS ${services.quoteIdentifier(name)} ON ${services.formatTableName(table)}${using} (${columns})${withClause}${where};`;
13973
+ };
13974
+ var createPostgresSchemaDialect = () => composeSchemaDialect({
13975
+ name: "postgres",
13976
+ quoteIdentifier: quoteIdentifier5,
13977
+ literalFormatter,
13978
+ renderColumnType: renderPostgresColumnType,
13979
+ renderAutoIncrement: (column) => {
13980
+ if (!column.autoIncrement) return void 0;
13981
+ const strategy = column.generated === "always" ? "GENERATED ALWAYS" : "GENERATED BY DEFAULT";
13982
+ return `${strategy} AS IDENTITY`;
13983
+ },
13984
+ renderIndex: renderPostgresIndex,
13985
+ renderReferenceSuffix: (ref) => ref.deferrable ? "DEFERRABLE INITIALLY DEFERRED" : void 0,
13986
+ supportsPartialIndexes: true,
13987
+ mutations: (services) => ({
13988
+ dropTable: createStandardDropTableCapability(services),
13989
+ dropColumn: createStandardDropColumnCapability(services),
13990
+ dropIndex: {
13991
+ compile(table, index) {
13992
+ const qualified = table.schema ? `${services.quoteIdentifier(table.schema)}.${services.quoteIdentifier(index)}` : services.quoteIdentifier(index);
13993
+ return [`DROP INDEX IF EXISTS ${qualified};`];
13994
+ }
13995
+ },
13996
+ alterColumn: {
13997
+ compile(table, column, actualColumn, diff) {
13998
+ void actualColumn;
13999
+ const statements = [];
14000
+ const tableName = services.formatTableName(table);
14001
+ const columnName = services.quoteIdentifier(column.name);
14002
+ if (diff.typeChanged) {
14003
+ statements.push(
14004
+ `ALTER TABLE ${tableName} ALTER COLUMN ${columnName} TYPE ${renderPostgresColumnType(column, services)};`
14005
+ );
14006
+ }
14007
+ if (diff.defaultChanged) {
14008
+ statements.push(
14009
+ column.default === void 0 ? `ALTER TABLE ${tableName} ALTER COLUMN ${columnName} DROP DEFAULT;` : `ALTER TABLE ${tableName} ALTER COLUMN ${columnName} SET DEFAULT ${services.renderDefault(column.default, column)};`
14010
+ );
14011
+ }
14012
+ if (diff.nullabilityChanged) {
14013
+ statements.push(
14014
+ `ALTER TABLE ${tableName} ALTER COLUMN ${columnName} ${column.notNull ? "SET" : "DROP"} NOT NULL;`
14015
+ );
14016
+ }
14017
+ if (diff.autoIncrementChanged) {
14018
+ if (column.autoIncrement) {
14019
+ const strategy = column.generated === "always" ? "ALWAYS" : "BY DEFAULT";
14020
+ statements.push(
14021
+ `ALTER TABLE ${tableName} ALTER COLUMN ${columnName} ADD GENERATED ${strategy} AS IDENTITY;`
14022
+ );
14023
+ } else {
14024
+ statements.push(`ALTER TABLE ${tableName} ALTER COLUMN ${columnName} DROP IDENTITY IF EXISTS;`);
14025
+ }
14026
+ }
14027
+ return statements;
14028
+ },
14029
+ warning(table, column, actualColumn, diff) {
14030
+ void table;
14031
+ void column;
14032
+ void actualColumn;
14033
+ return diff.autoIncrementChanged ? "Altering identity properties may fail if an existing sequence is attached; verify generated column state." : void 0;
14034
+ }
14035
+ }
14036
+ })
14037
+ });
14038
+ var PostgresSchemaDialect = class {
14039
+ delegate = createPostgresSchemaDialect();
14040
+ name = this.delegate.name;
14041
+ mutations = this.delegate.mutations;
14042
+ quoteIdentifier(id) {
14043
+ return this.delegate.quoteIdentifier(id);
14044
+ }
14045
+ formatTableName(table) {
14046
+ return this.delegate.formatTableName(table);
14047
+ }
14048
+ renderColumnType(column) {
14049
+ return this.delegate.renderColumnType(column);
14050
+ }
14051
+ renderDefault(value, column) {
14052
+ return this.delegate.renderDefault(value, column);
14053
+ }
14054
+ renderAutoIncrement(column, table) {
14055
+ return this.delegate.renderAutoIncrement(column, table);
14056
+ }
14057
+ renderReference(ref, table) {
14058
+ return this.delegate.renderReference(ref, table);
14059
+ }
14060
+ renderIndex(table, index) {
14061
+ return this.delegate.renderIndex(table, index);
14062
+ }
14063
+ renderTableOptions(table) {
14064
+ return this.delegate.renderTableOptions(table);
14065
+ }
14066
+ supportsPartialIndexes() {
14067
+ return this.delegate.supportsPartialIndexes();
14068
+ }
14069
+ preferInlinePkAutoincrement(column, table, pk) {
14070
+ return this.delegate.preferInlinePkAutoincrement(column, table, pk);
14071
+ }
14072
+ };
14073
+
14074
+ // src/core/ddl/dialects/mysql-schema-dialect.ts
14075
+ var quoteIdentifier6 = (id) => `\`${id}\``;
14076
+ var literalFormatter2 = createLiteralFormatter({ booleanTrue: "1", booleanFalse: "0" });
14077
+ var renderMySqlColumnType = (column, services) => {
14078
+ const override = column.dialectTypes?.[services.name] ?? column.dialectTypes?.default;
14079
+ if (override) return renderTypeWithArgs(override, column.args);
14080
+ const type = normalizeColumnType(column.type);
14081
+ switch (type) {
14082
+ case "int":
14083
+ case "integer":
14084
+ return "INT";
14085
+ case "bigint":
14086
+ return "BIGINT";
14087
+ case "uuid":
14088
+ return "CHAR(36)";
14089
+ case "boolean":
14090
+ return "TINYINT(1)";
14091
+ case "json":
14092
+ return "JSON";
14093
+ case "decimal":
14094
+ return column.args?.length ? `DECIMAL(${column.args[0]},${column.args[1] ?? 0})` : "DECIMAL";
14095
+ case "float":
14096
+ return column.args?.length ? `FLOAT(${column.args[0]})` : "FLOAT";
14097
+ case "double":
14098
+ return "DOUBLE";
14099
+ case "timestamptz":
14100
+ case "timestamp":
14101
+ return "TIMESTAMP";
14102
+ case "datetime":
14103
+ return "DATETIME";
14104
+ case "date":
14105
+ return "DATE";
14106
+ case "varchar":
14107
+ return column.args?.length ? `VARCHAR(${column.args[0]})` : "VARCHAR(255)";
14108
+ case "text":
14109
+ return "TEXT";
14110
+ case "binary":
14111
+ return column.args?.length ? `BINARY(${column.args[0]})` : "BINARY(255)";
14112
+ case "varbinary":
14113
+ return column.args?.length ? `VARBINARY(${column.args[0]})` : "VARBINARY(255)";
14114
+ case "blob":
14115
+ case "bytea":
14116
+ return "BLOB";
14117
+ case "enum":
14118
+ return column.args?.length ? `ENUM(${column.args.map((value) => `'${escapeSqlString(String(value))}'`).join(",")})` : "ENUM";
14119
+ case "vector":
14120
+ case "halfvec": {
14121
+ const dimensions = column.vectorOptions?.dimensions ?? column.args?.[0] ?? 3;
14122
+ return `VECTOR(${dimensions})`;
14123
+ }
14124
+ default:
14125
+ return renderTypeWithArgs(String(type).toUpperCase(), column.args);
14126
+ }
14127
+ };
14128
+ var createMySqlSchemaDialect = () => {
14129
+ let dialect;
14130
+ dialect = composeSchemaDialect({
14131
+ name: "mysql",
14132
+ quoteIdentifier: quoteIdentifier6,
14133
+ literalFormatter: literalFormatter2,
14134
+ renderColumnType: renderMySqlColumnType,
14135
+ renderAutoIncrement: (column) => column.autoIncrement ? "AUTO_INCREMENT" : void 0,
14136
+ renderIndex(table, index, services) {
14137
+ if (index.where) throw new Error("MySQL does not support partial/filtered indexes");
14138
+ const name = index.name || deriveIndexName(table, index);
14139
+ const columns = renderIndexColumns(services, index.columns);
14140
+ const unique = index.unique ? "UNIQUE " : "";
14141
+ return `CREATE ${unique}INDEX ${services.quoteIdentifier(name)} ON ${services.formatTableName(table)} (${columns});`;
14142
+ },
14143
+ renderTableOptions(table) {
14144
+ const parts = [];
14145
+ if (table.engine) parts.push(`ENGINE=${table.engine}`);
14146
+ if (table.charset) parts.push(`DEFAULT CHARSET=${table.charset}`);
14147
+ if (table.collation) parts.push(`COLLATE=${table.collation}`);
14148
+ return parts.length ? parts.join(" ") : void 0;
14149
+ },
14150
+ mutations: (services) => ({
14151
+ dropTable: createStandardDropTableCapability(services),
14152
+ dropColumn: createStandardDropColumnCapability(services),
14153
+ dropIndex: {
14154
+ compile: (table, index) => [
14155
+ `DROP INDEX ${services.quoteIdentifier(index)} ON ${services.formatTableName(table)};`
14156
+ ]
14157
+ },
14158
+ alterColumn: {
14159
+ compile(table, column, actualColumn, diff) {
14160
+ void actualColumn;
14161
+ void diff;
14162
+ const rendered = renderColumnDefinition(table, column, dialect);
14163
+ return [`ALTER TABLE ${services.formatTableName(table)} MODIFY COLUMN ${rendered.sql};`];
14164
+ }
14165
+ }
14166
+ })
14167
+ });
14168
+ return dialect;
14169
+ };
14170
+ var MySqlSchemaDialect = class {
14171
+ delegate = createMySqlSchemaDialect();
14172
+ name = this.delegate.name;
14173
+ mutations = this.delegate.mutations;
14174
+ quoteIdentifier(id) {
14175
+ return this.delegate.quoteIdentifier(id);
14176
+ }
14177
+ formatTableName(table) {
14178
+ return this.delegate.formatTableName(table);
14179
+ }
14180
+ renderColumnType(column) {
14181
+ return this.delegate.renderColumnType(column);
14182
+ }
14183
+ renderDefault(value, column) {
14184
+ return this.delegate.renderDefault(value, column);
14185
+ }
14186
+ renderAutoIncrement(column, table) {
14187
+ return this.delegate.renderAutoIncrement(column, table);
14188
+ }
14189
+ renderReference(ref, table) {
14190
+ return this.delegate.renderReference(ref, table);
14191
+ }
14192
+ renderIndex(table, index) {
14193
+ return this.delegate.renderIndex(table, index);
14194
+ }
14195
+ renderTableOptions(table) {
14196
+ return this.delegate.renderTableOptions(table);
14197
+ }
14198
+ supportsPartialIndexes() {
14199
+ return this.delegate.supportsPartialIndexes();
14200
+ }
14201
+ preferInlinePkAutoincrement(column, table, pk) {
14202
+ return this.delegate.preferInlinePkAutoincrement(column, table, pk);
14203
+ }
14204
+ };
14205
+
14206
+ // src/core/ddl/dialects/sqlite-schema-dialect.ts
14207
+ var quoteIdentifier7 = (id) => `"${id}"`;
14208
+ var literalFormatter3 = createLiteralFormatter({ booleanTrue: "1", booleanFalse: "0" });
14209
+ var renderSqliteColumnType = (column, services) => {
14210
+ const override = column.dialectTypes?.[services.name] ?? column.dialectTypes?.default;
14211
+ if (override) return renderTypeWithArgs(override, column.args);
14212
+ const type = normalizeColumnType(column.type);
14213
+ switch (type) {
14214
+ case "int":
14215
+ case "integer":
14216
+ case "bigint":
14217
+ case "boolean":
14218
+ return "INTEGER";
14219
+ case "decimal":
14220
+ case "float":
14221
+ case "double":
14222
+ return "REAL";
14223
+ case "date":
14224
+ case "datetime":
14225
+ case "timestamp":
14226
+ case "timestamptz":
14227
+ case "varchar":
14228
+ case "text":
14229
+ case "json":
14230
+ case "uuid":
14231
+ case "enum":
14232
+ return "TEXT";
14233
+ case "binary":
14234
+ case "varbinary":
14235
+ case "blob":
14236
+ case "bytea":
14237
+ return "BLOB";
14238
+ case "halfvec": {
14239
+ const dimensions = column.vectorOptions?.dimensions ?? column.args?.[0] ?? 3;
14240
+ return `float16[${dimensions}]`;
14241
+ }
14242
+ case "vector": {
14243
+ const dimensions = column.vectorOptions?.dimensions ?? column.args?.[0] ?? 3;
14244
+ const elementType = column.vectorOptions?.elementType === "float16" ? "float16" : "float32";
14245
+ return `${elementType}[${dimensions}]`;
14246
+ }
14247
+ default:
14248
+ return "TEXT";
14249
+ }
14250
+ };
14251
+ var createSqliteSchemaDialect = () => composeSchemaDialect({
14252
+ name: "sqlite",
14253
+ quoteIdentifier: quoteIdentifier7,
14254
+ literalFormatter: literalFormatter3,
14255
+ renderColumnType: renderSqliteColumnType,
14256
+ renderAutoIncrement(column, table) {
14257
+ const primaryKey = resolvePrimaryKey(table);
14258
+ return column.autoIncrement && primaryKey.length === 1 && primaryKey[0] === column.name ? "PRIMARY KEY AUTOINCREMENT" : void 0;
14259
+ },
14260
+ preferInlinePkAutoincrement: (column, table, primaryKey) => {
14261
+ void table;
14262
+ return !!(column.autoIncrement && primaryKey.length === 1 && primaryKey[0] === column.name);
14263
+ },
14264
+ renderIndex(table, index, services) {
14265
+ const name = index.name || deriveIndexName(table, index);
14266
+ const columns = renderIndexColumns(services, index.columns);
14267
+ const unique = index.unique ? "UNIQUE " : "";
14268
+ const where = index.where ? ` WHERE ${index.where}` : "";
14269
+ return `CREATE ${unique}INDEX IF NOT EXISTS ${services.quoteIdentifier(name)} ON ${services.formatTableName(table)} (${columns})${where};`;
14270
+ },
14271
+ supportsPartialIndexes: true,
14272
+ mutations: (services) => ({
14273
+ dropTable: createStandardDropTableCapability(services),
14274
+ dropIndex: {
14275
+ compile: (_table, index) => [`DROP INDEX IF EXISTS ${services.quoteIdentifier(index)};`]
14276
+ }
14277
+ })
14278
+ });
14279
+ var SQLiteSchemaDialect = class {
14280
+ delegate = createSqliteSchemaDialect();
14281
+ name = this.delegate.name;
14282
+ mutations = this.delegate.mutations;
14283
+ quoteIdentifier(id) {
14284
+ return this.delegate.quoteIdentifier(id);
14285
+ }
14286
+ formatTableName(table) {
14287
+ return this.delegate.formatTableName(table);
14288
+ }
14289
+ renderColumnType(column) {
14290
+ return this.delegate.renderColumnType(column);
14291
+ }
14292
+ renderDefault(value, column) {
14293
+ return this.delegate.renderDefault(value, column);
14294
+ }
14295
+ renderAutoIncrement(column, table) {
14296
+ return this.delegate.renderAutoIncrement(column, table);
14297
+ }
14298
+ renderReference(ref, table) {
14299
+ return this.delegate.renderReference(ref, table);
14300
+ }
14301
+ renderIndex(table, index) {
14302
+ return this.delegate.renderIndex(table, index);
14303
+ }
14304
+ renderTableOptions(table) {
14305
+ return this.delegate.renderTableOptions(table);
14306
+ }
14307
+ supportsPartialIndexes() {
14308
+ return this.delegate.supportsPartialIndexes();
14309
+ }
14310
+ preferInlinePkAutoincrement(column, table, pk) {
14311
+ return this.delegate.preferInlinePkAutoincrement(column, table, pk);
14312
+ }
14313
+ };
14314
+
14315
+ // src/core/ddl/dialects/mssql-schema-dialect.ts
14316
+ var quoteIdentifier8 = (id) => `[${id.replace(/]/g, "]]")}]`;
14317
+ var literalFormatter4 = createLiteralFormatter({ booleanTrue: "1", booleanFalse: "0" });
14318
+ var renderMssqlColumnType = (column, services) => {
14319
+ const override = column.dialectTypes?.[services.name] ?? column.dialectTypes?.default;
14320
+ if (override) return renderTypeWithArgs(override, column.args);
14321
+ const type = normalizeColumnType(column.type);
14322
+ switch (type) {
14323
+ case "int":
14324
+ case "integer":
14325
+ return "INT";
14326
+ case "bigint":
14327
+ return "BIGINT";
14328
+ case "uuid":
14329
+ return "UNIQUEIDENTIFIER";
14330
+ case "boolean":
14331
+ return "BIT";
14332
+ case "json":
14333
+ return "NVARCHAR(MAX)";
14334
+ case "decimal":
14335
+ return column.args?.length ? `DECIMAL(${column.args[0]},${column.args[1] ?? 0})` : "DECIMAL(18,0)";
14336
+ case "float":
14337
+ case "double":
14338
+ return "FLOAT";
14339
+ case "timestamptz":
14340
+ case "timestamp":
14341
+ case "datetime":
14342
+ return "DATETIME2";
14343
+ case "date":
14344
+ return "DATE";
14345
+ case "varchar":
14346
+ return column.args?.length ? `NVARCHAR(${column.args[0]})` : "NVARCHAR(255)";
14347
+ case "text":
14348
+ return "NVARCHAR(MAX)";
14349
+ case "binary": {
14350
+ const length2 = column.args?.[0];
14351
+ return length2 !== void 0 ? `BINARY(${length2})` : "BINARY(255)";
14352
+ }
14353
+ case "varbinary": {
14354
+ const length2 = column.args?.[0];
14355
+ if (typeof length2 === "string" && length2.toLowerCase() === "max") return "VARBINARY(MAX)";
14356
+ return length2 !== void 0 ? `VARBINARY(${length2})` : "VARBINARY(255)";
14357
+ }
14358
+ case "blob":
14359
+ case "bytea":
14360
+ return "VARBINARY(MAX)";
14361
+ case "enum":
14362
+ return "NVARCHAR(255)";
14363
+ case "vector": {
14364
+ const dimensions = column.vectorOptions?.dimensions ?? column.args?.[0] ?? 3;
14365
+ const elementType = column.vectorOptions?.elementType;
14366
+ return elementType ? `VECTOR(${dimensions}, ${elementType})` : `VECTOR(${dimensions})`;
14367
+ }
14368
+ case "halfvec": {
14369
+ const dimensions = column.vectorOptions?.dimensions ?? column.args?.[0] ?? 3;
14370
+ return `VECTOR(${dimensions}, float16)`;
14371
+ }
14372
+ default:
14373
+ return renderTypeWithArgs(String(type).toUpperCase(), column.args);
14374
+ }
14375
+ };
14376
+ var createMssqlSchemaDialect = () => composeSchemaDialect({
14377
+ name: "mssql",
14378
+ quoteIdentifier: quoteIdentifier8,
14379
+ literalFormatter: literalFormatter4,
14380
+ renderColumnType: renderMssqlColumnType,
14381
+ renderAutoIncrement: (column) => column.autoIncrement ? "IDENTITY(1,1)" : void 0,
14382
+ renderIndex(table, index, services) {
14383
+ const name = index.name || deriveIndexName(table, index);
14384
+ const columns = renderIndexColumns(services, index.columns);
14385
+ const unique = index.unique ? "UNIQUE " : "";
14386
+ const where = index.where ? ` WHERE ${index.where}` : "";
14387
+ return `CREATE ${unique}INDEX ${services.quoteIdentifier(name)} ON ${services.formatTableName(table)} (${columns})${where};`;
14388
+ },
14389
+ supportsPartialIndexes: true,
14390
+ mutations: (services) => ({
14391
+ dropTable: createStandardDropTableCapability(services),
14392
+ dropColumn: createStandardDropColumnCapability(services),
14393
+ dropIndex: {
14394
+ compile: (table, index) => [
14395
+ `DROP INDEX ${services.quoteIdentifier(index)} ON ${services.formatTableName(table)};`
14396
+ ]
14397
+ },
14398
+ alterColumn: {
14399
+ compile(table, column, actualColumn, diff) {
14400
+ void actualColumn;
14401
+ const statements = [];
14402
+ if (diff.typeChanged || diff.nullabilityChanged) {
14403
+ const nullability = column.notNull ? "NOT NULL" : "NULL";
14404
+ statements.push(
14405
+ `ALTER TABLE ${services.formatTableName(table)} ALTER COLUMN ${services.quoteIdentifier(column.name)} ${renderMssqlColumnType(column, services)} ${nullability};`
14406
+ );
14407
+ }
14408
+ return statements;
14409
+ },
14410
+ warning(table, column, actualColumn, diff) {
14411
+ void table;
14412
+ void column;
14413
+ void actualColumn;
14414
+ return diff.defaultChanged || diff.autoIncrementChanged ? "Altering defaults or identity on MSSQL is not automated (requires dropping/adding default or identity constraints manually)." : void 0;
14415
+ }
14416
+ }
14417
+ })
14418
+ });
14419
+ var MSSqlSchemaDialect = class {
14420
+ delegate = createMssqlSchemaDialect();
14421
+ name = this.delegate.name;
14422
+ mutations = this.delegate.mutations;
14423
+ quoteIdentifier(id) {
14424
+ return this.delegate.quoteIdentifier(id);
14425
+ }
14426
+ formatTableName(table) {
14427
+ return this.delegate.formatTableName(table);
14428
+ }
14429
+ renderColumnType(column) {
14430
+ return this.delegate.renderColumnType(column);
14431
+ }
14432
+ renderDefault(value, column) {
14433
+ return this.delegate.renderDefault(value, column);
14434
+ }
14435
+ renderAutoIncrement(column, table) {
14436
+ return this.delegate.renderAutoIncrement(column, table);
14437
+ }
14438
+ renderReference(ref, table) {
14439
+ return this.delegate.renderReference(ref, table);
14440
+ }
14441
+ renderIndex(table, index) {
14442
+ return this.delegate.renderIndex(table, index);
14443
+ }
14444
+ renderTableOptions(table) {
14445
+ return this.delegate.renderTableOptions(table);
14446
+ }
14447
+ supportsPartialIndexes() {
14448
+ return this.delegate.supportsPartialIndexes();
14449
+ }
14450
+ preferInlinePkAutoincrement(column, table, pk) {
14451
+ return this.delegate.preferInlinePkAutoincrement(column, table, pk);
14452
+ }
14453
+ };
14454
+
13830
14455
  // src/core/functions/numeric.ts
13831
14456
  var isColumnDef2 = (val) => !!val && typeof val === "object" && "type" in val && "name" in val;
13832
14457
  var toOperand3 = (input) => {
@@ -22311,7 +22936,6 @@ async function bulkUpsert(session, table, rows, options = {}) {
22311
22936
  DefaultMorphToReference,
22312
22937
  DefaultTypeStrategy,
22313
22938
  DeleteQueryBuilder,
22314
- DialectBase,
22315
22939
  DialectFactory,
22316
22940
  DomainEventBus,
22317
22941
  Email,
@@ -22325,6 +22949,7 @@ async function bulkUpsert(session, table, rows, options = {}) {
22325
22949
  KeyvCacheAdapter,
22326
22950
  Length,
22327
22951
  Lower,
22952
+ MSSqlSchemaDialect,
22328
22953
  MemoryCacheAdapter,
22329
22954
  MorphMany,
22330
22955
  MorphOne,
@@ -22337,6 +22962,7 @@ async function bulkUpsert(session, table, rows, options = {}) {
22337
22962
  MssqlUpdateCompiler,
22338
22963
  MySqlDialect,
22339
22964
  MySqlProcedureCompiler,
22965
+ MySqlSchemaDialect,
22340
22966
  MySqlUpsertStrategy,
22341
22967
  NestedSetStrategy,
22342
22968
  NoReturningStrategy,
@@ -22348,6 +22974,7 @@ async function bulkUpsert(session, table, rows, options = {}) {
22348
22974
  PostgresDialect,
22349
22975
  PostgresProcedureCompiler,
22350
22976
  PostgresReturningStrategy,
22977
+ PostgresSchemaDialect,
22351
22978
  PostgresUpsertStrategy,
22352
22979
  PrimaryKey,
22353
22980
  ProcedureCallBuilder,
@@ -22355,9 +22982,9 @@ async function bulkUpsert(session, table, rows, options = {}) {
22355
22982
  QueryCacheManager,
22356
22983
  RedisCacheAdapter,
22357
22984
  RelationKinds,
22985
+ SQLiteSchemaDialect,
22358
22986
  STANDARD_COLUMN_TYPES,
22359
22987
  SelectQueryBuilder,
22360
- SqlDialectBase,
22361
22988
  SqlServerDialect,
22362
22989
  SqliteDialect,
22363
22990
  SqliteReturningStrategy,
@@ -22439,6 +23066,8 @@ async function bulkUpsert(session, table, rows, options = {}) {
22439
23066
  columnToOpenApiSchema,
22440
23067
  columnTypeToOpenApiFormat,
22441
23068
  columnTypeToOpenApiType,
23069
+ composeSchemaDialect,
23070
+ composeSqlDialect,
22442
23071
  computePaginationMetadata,
22443
23072
  computeSchemaHash,
22444
23073
  concat,
@@ -22456,14 +23085,26 @@ async function bulkUpsert(session, table, rows, options = {}) {
22456
23085
  createEntityFromRow,
22457
23086
  createEntityProxy,
22458
23087
  createExecutorFromQueryRunner,
23088
+ createLiteralFormatter,
22459
23089
  createMssqlCompilerSet,
22460
23090
  createMssqlExecutor,
23091
+ createMssqlSchemaDialect,
23092
+ createMySqlDialect,
23093
+ createMySqlSchemaDialect,
22461
23094
  createMysqlExecutor,
22462
23095
  createPooledExecutorFactory,
23096
+ createPostgresDialect,
22463
23097
  createPostgresExecutor,
23098
+ createPostgresSchemaDialect,
22464
23099
  createQueryLoggingExecutor,
22465
23100
  createRef,
23101
+ createSqlDialect,
23102
+ createSqlServerDialect,
23103
+ createSqliteDialect,
22466
23104
  createSqliteExecutor,
23105
+ createSqliteSchemaDialect,
23106
+ createStandardDropColumnCapability,
23107
+ createStandardDropTableCapability,
22467
23108
  createTediousExecutor,
22468
23109
  createTediousMssqlClient,
22469
23110
  createTreeManager,