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.js CHANGED
@@ -1533,159 +1533,6 @@ var SelectAstNormalizer = class {
1533
1533
  }
1534
1534
  };
1535
1535
 
1536
- // src/core/dialect/abstract.ts
1537
- var DialectBase = class _DialectBase {
1538
- expressionCompilerRegistry;
1539
- selectAstNormalizer;
1540
- functionStrategy;
1541
- tableFunctionStrategy;
1542
- constructor(functionStrategy, tableFunctionStrategy) {
1543
- this.functionStrategy = functionStrategy ?? new StandardFunctionStrategy();
1544
- this.tableFunctionStrategy = tableFunctionStrategy ?? new StandardTableFunctionStrategy();
1545
- this.selectAstNormalizer = new SelectAstNormalizer((kind) => this.supportsSetOperation(kind));
1546
- this.expressionCompilerRegistry = new ExpressionCompilerRegistry({
1547
- quoteIdentifier: (id) => this.quoteIdentifier(id),
1548
- compileSelectAst: (ast, ctx) => this.compileSelectAst(ast, ctx),
1549
- compileSelectForExists: (ast, ctx) => this.compileSelectForExists(ast, ctx),
1550
- compileJsonPath: (node) => this.compileJsonPath(node),
1551
- compileFunctionOperand: (node, ctx) => this.compileFunctionOperand(node, ctx),
1552
- describe: () => this.constructor.name
1553
- });
1554
- }
1555
- compileSelect(ast) {
1556
- const ctx = this.createCompilerContext();
1557
- const normalized = this.normalizeSelectAst(ast);
1558
- const rawSql = this.compileSelectAst(normalized, ctx).trim();
1559
- return {
1560
- sql: rawSql.endsWith(";") ? rawSql : `${rawSql};`,
1561
- params: [...ctx.params]
1562
- };
1563
- }
1564
- compileInsert(ast) {
1565
- const ctx = this.createCompilerContext();
1566
- const rawSql = this.compileInsertAst(ast, ctx).trim();
1567
- return {
1568
- sql: rawSql.endsWith(";") ? rawSql : `${rawSql};`,
1569
- params: [...ctx.params]
1570
- };
1571
- }
1572
- compileUpdate(ast) {
1573
- const ctx = this.createCompilerContext();
1574
- const rawSql = this.compileUpdateAst(ast, ctx).trim();
1575
- return {
1576
- sql: rawSql.endsWith(";") ? rawSql : `${rawSql};`,
1577
- params: [...ctx.params]
1578
- };
1579
- }
1580
- compileDelete(ast) {
1581
- const ctx = this.createCompilerContext();
1582
- const rawSql = this.compileDeleteAst(ast, ctx).trim();
1583
- return {
1584
- sql: rawSql.endsWith(";") ? rawSql : `${rawSql};`,
1585
- params: [...ctx.params]
1586
- };
1587
- }
1588
- supportsDmlReturningClause() {
1589
- return false;
1590
- }
1591
- compileWhere(where, ctx) {
1592
- if (!where) return "";
1593
- return ` WHERE ${this.compileExpression(where, ctx)}`;
1594
- }
1595
- compileReturning(returning, _ctx) {
1596
- void _ctx;
1597
- if (!returning || returning.length === 0) return "";
1598
- throw new Error("RETURNING is not supported by this dialect.");
1599
- }
1600
- compileSelectForExists(ast, ctx) {
1601
- const normalized = this.normalizeSelectAst(ast);
1602
- const full = this.compileSelectAst(normalized, ctx).trim().replace(/;$/, "");
1603
- if (normalized.setOps && normalized.setOps.length > 0) {
1604
- return `SELECT 1 FROM (${full}) AS _exists`;
1605
- }
1606
- const upper2 = full.toUpperCase();
1607
- const fromIndex = upper2.indexOf(" FROM ");
1608
- if (fromIndex === -1) return full;
1609
- return `SELECT 1${full.slice(fromIndex)}`;
1610
- }
1611
- createCompilerContext() {
1612
- const params = [];
1613
- let counter = 0;
1614
- return {
1615
- params,
1616
- addParameter: (value) => {
1617
- counter += 1;
1618
- params.push(value);
1619
- return this.formatPlaceholder(counter);
1620
- }
1621
- };
1622
- }
1623
- formatPlaceholder(_index) {
1624
- void _index;
1625
- return "?";
1626
- }
1627
- supportsSetOperation(_kind) {
1628
- void _kind;
1629
- return true;
1630
- }
1631
- normalizeSelectAst(ast) {
1632
- return this.selectAstNormalizer.normalize(ast);
1633
- }
1634
- registerExpressionCompiler(type, compiler) {
1635
- this.expressionCompilerRegistry.registerExpressionCompiler(type, compiler);
1636
- }
1637
- registerOperandCompiler(type, compiler) {
1638
- this.expressionCompilerRegistry.registerOperandCompiler(type, compiler);
1639
- }
1640
- compileExpression(node, ctx) {
1641
- return this.expressionCompilerRegistry.compileExpression(node, ctx);
1642
- }
1643
- compileOperand(node, ctx) {
1644
- return this.expressionCompilerRegistry.compileOperand(node, ctx);
1645
- }
1646
- compileOrderingTerm(term, ctx) {
1647
- return this.expressionCompilerRegistry.compileOrderingTerm(term, ctx);
1648
- }
1649
- compileJsonPath(_node) {
1650
- void _node;
1651
- throw new Error("JSON Path not supported by this dialect");
1652
- }
1653
- compileFunctionOperand(fnNode, ctx) {
1654
- const compiledArgs = fnNode.args.map((arg) => this.compileOperand(arg, ctx));
1655
- const renderer = this.functionStrategy.getRenderer(fnNode.name);
1656
- if (renderer) {
1657
- return renderer({
1658
- node: fnNode,
1659
- compiledArgs,
1660
- compileOperand: (operand) => this.compileOperand(operand, ctx)
1661
- });
1662
- }
1663
- return `${fnNode.name}(${compiledArgs.join(", ")})`;
1664
- }
1665
- /** Creates a minimal dialect implementation for isolated compiler tests. */
1666
- static create(functionStrategy, tableFunctionStrategy) {
1667
- class TestDialect extends _DialectBase {
1668
- dialect = "sqlite";
1669
- quoteIdentifier(id) {
1670
- return `"${id}"`;
1671
- }
1672
- compileSelectAst() {
1673
- throw new Error("Not implemented");
1674
- }
1675
- compileInsertAst() {
1676
- throw new Error("Not implemented");
1677
- }
1678
- compileUpdateAst() {
1679
- throw new Error("Not implemented");
1680
- }
1681
- compileDeleteAst() {
1682
- throw new Error("Not implemented");
1683
- }
1684
- }
1685
- return new TestDialect(functionStrategy, tableFunctionStrategy);
1686
- }
1687
- };
1688
-
1689
1536
  // src/core/dialect/base/pagination-strategy.ts
1690
1537
  var StandardLimitOffsetPagination = class {
1691
1538
  /**
@@ -1710,19 +1557,19 @@ var NoReturningStrategy = class {
1710
1557
  if (!returning || returning.length === 0) return "";
1711
1558
  throw new Error("RETURNING is not supported by this dialect.");
1712
1559
  }
1713
- formatReturningColumns(returning, quoteIdentifier) {
1560
+ formatReturningColumns(returning, quoteIdentifier5) {
1714
1561
  return returning.map((column) => {
1715
- const tablePart = column.table ? `${quoteIdentifier(column.table)}.` : "";
1716
- const aliasPart = column.alias ? ` AS ${quoteIdentifier(column.alias)}` : "";
1717
- return `${tablePart}${quoteIdentifier(column.name)}${aliasPart}`;
1562
+ const tablePart = column.table ? `${quoteIdentifier5(column.table)}.` : "";
1563
+ const aliasPart = column.alias ? ` AS ${quoteIdentifier5(column.alias)}` : "";
1564
+ return `${tablePart}${quoteIdentifier5(column.name)}${aliasPart}`;
1718
1565
  }).join(", ");
1719
1566
  }
1720
1567
  };
1721
1568
  var StandardReturningStrategy = class extends NoReturningStrategy {
1722
- compileReturning(returning, _ctx, quoteIdentifier) {
1569
+ compileReturning(returning, _ctx, quoteIdentifier5) {
1723
1570
  void _ctx;
1724
1571
  if (!returning || returning.length === 0) return "";
1725
- return ` RETURNING ${this.formatReturningColumns(returning, quoteIdentifier)}`;
1572
+ return ` RETURNING ${this.formatReturningColumns(returning, quoteIdentifier5)}`;
1726
1573
  }
1727
1574
  };
1728
1575
 
@@ -1853,13 +1700,13 @@ var CteCompiler = class {
1853
1700
  * @param stripTrailingSemicolon - Function to remove trailing semicolons from SQL.
1854
1701
  * @returns SQL WITH clause string (e.g., "WITH cte_name AS (...) ") or empty string if no CTEs.
1855
1702
  */
1856
- static compileCtes(ast, ctx, quoteIdentifier, compileSelectAst, normalizeSelectAst, stripTrailingSemicolon) {
1703
+ static compileCtes(ast, ctx, quoteIdentifier5, compileSelectAst, normalizeSelectAst, stripTrailingSemicolon) {
1857
1704
  if (!ast.ctes || ast.ctes.length === 0) return "";
1858
1705
  const hasRecursive = ast.ctes.some((cte) => cte.recursive);
1859
1706
  const prefix = hasRecursive ? "WITH RECURSIVE " : "WITH ";
1860
1707
  const cteDefs = ast.ctes.map((cte) => {
1861
- const name = quoteIdentifier(cte.name);
1862
- const cols = cte.columns && cte.columns.length ? `(${cte.columns.map((c) => quoteIdentifier(c)).join(", ")})` : "";
1708
+ const name = quoteIdentifier5(cte.name);
1709
+ const cols = cte.columns && cte.columns.length ? `(${cte.columns.map((c) => quoteIdentifier5(c)).join(", ")})` : "";
1863
1710
  const query = stripTrailingSemicolon(compileSelectAst(normalizeSelectAst(cte.query), ctx));
1864
1711
  return `${name}${cols} AS (${query})`;
1865
1712
  }).join(", ");
@@ -2082,138 +1929,174 @@ var StandardDeleteCompiler = class {
2082
1929
  }
2083
1930
  };
2084
1931
 
2085
- // src/core/dialect/base/sql-dialect.ts
2086
- var SqlDialectBase = class extends DialectBase {
2087
- paginationStrategy;
2088
- returningStrategy;
2089
- upsertStrategy;
2090
- dmlReturningSupported;
2091
- sourceCompiler;
2092
- standardUpdateCompiler;
2093
- compilerSet;
2094
- constructor(options = {}) {
2095
- super(options.functionStrategy, options.tableFunctionStrategy);
2096
- this.paginationStrategy = options.paginationStrategy ?? new StandardLimitOffsetPagination();
2097
- this.returningStrategy = options.returningStrategy ?? new NoReturningStrategy();
2098
- this.upsertStrategy = options.upsertStrategy ?? new NoUpsertStrategy();
2099
- this.dmlReturningSupported = options.supportsDmlReturning ?? false;
2100
- const services = {
2101
- getDialectName: () => this.dialect,
2102
- getPaginationStrategy: () => this.paginationStrategy,
2103
- getTableFunctionStrategy: () => this.tableFunctionStrategy,
2104
- quoteIdentifier: (id) => this.quoteIdentifier(id),
2105
- compileOperand: (node, ctx) => this.compileOperand(node, ctx),
2106
- compileExpression: (node, ctx) => this.compileExpression(node, ctx),
2107
- compileOrderingTerm: (term, ctx) => this.compileOrderingTerm(term, ctx),
2108
- normalizeSelectAst: (ast) => this.normalizeSelectAst(ast),
2109
- compileSelectAst: (ast, ctx) => this.compileSelectAst(ast, ctx),
2110
- compileReturning: (returning, ctx) => this.compileReturning(returning, ctx),
2111
- compileUpsertClause: (ast, ctx) => this.compileUpsertClause(ast, ctx),
2112
- compileSetTarget: (column, table) => this.compileSetTarget(column, table),
2113
- renderOrderByNulls: (order) => this.renderOrderByNulls(order),
2114
- renderOrderByCollation: (order) => this.renderOrderByCollation(order)
2115
- };
2116
- this.sourceCompiler = new StandardSqlSourceCompiler(services);
2117
- const standardSelect = new StandardSelectCompiler(services, this.sourceCompiler);
2118
- const standardInsert = new StandardInsertCompiler(services, this.sourceCompiler);
2119
- this.standardUpdateCompiler = new StandardUpdateCompiler(services, this.sourceCompiler);
2120
- const standardDelete = new StandardDeleteCompiler(services, this.sourceCompiler);
2121
- const overrides = options.compilerFactory?.({
2122
- services,
2123
- sources: this.sourceCompiler
2124
- }) ?? {};
2125
- this.compilerSet = {
2126
- select: overrides.select ?? standardSelect,
2127
- insert: overrides.insert ?? standardInsert,
2128
- update: overrides.update ?? this.standardUpdateCompiler,
2129
- delete: overrides.delete ?? standardDelete
1932
+ // src/core/dialect/base/sql-dialect-composer.ts
1933
+ var terminate = (sql) => {
1934
+ const trimmed = sql.trim();
1935
+ return trimmed.endsWith(";") ? trimmed : `${trimmed};`;
1936
+ };
1937
+ var composeSqlDialect = (config) => {
1938
+ const functionStrategy = config.functionStrategy ?? new StandardFunctionStrategy();
1939
+ const tableFunctionStrategy = config.tableFunctionStrategy ?? new StandardTableFunctionStrategy();
1940
+ const paginationStrategy = config.paginationStrategy ?? new StandardLimitOffsetPagination();
1941
+ const returningStrategy = config.returningStrategy ?? new NoReturningStrategy();
1942
+ const upsertStrategy = config.upsertStrategy ?? new NoUpsertStrategy();
1943
+ const selectAstNormalizer = new SelectAstNormalizer(
1944
+ (kind) => config.supportsSetOperation?.(kind) ?? true
1945
+ );
1946
+ let compilerSet;
1947
+ let expressionRegistry2;
1948
+ const createCompilerContext = () => {
1949
+ const params = [];
1950
+ let counter = 0;
1951
+ return {
1952
+ params,
1953
+ addParameter(value) {
1954
+ counter += 1;
1955
+ params.push(value);
1956
+ return config.formatPlaceholder?.(counter) ?? "?";
1957
+ }
2130
1958
  };
2131
- }
2132
- supportsDmlReturningClause() {
2133
- return this.dmlReturningSupported;
2134
- }
2135
- compileSelectAst(ast, ctx) {
2136
- return this.compilerSet.select.compile(ast, ctx);
2137
- }
2138
- compileInsertAst(ast, ctx) {
2139
- return this.compilerSet.insert.compile(ast, ctx);
2140
- }
2141
- compileUpdateAst(ast, ctx) {
2142
- return this.compilerSet.update.compile(ast, ctx);
2143
- }
2144
- compileDeleteAst(ast, ctx) {
2145
- return this.compilerSet.delete.compile(ast, ctx);
2146
- }
2147
- compileUpsertClause(ast, ctx) {
2148
- return this.upsertStrategy.compile(ast, ctx, {
2149
- getDialectName: () => this.dialect,
2150
- quoteIdentifier: (id) => this.quoteIdentifier(id),
2151
- compileOperand: (node, compilerContext) => this.compileOperand(node, compilerContext),
2152
- compileExpression: (node, compilerContext) => this.compileExpression(node, compilerContext),
2153
- compileUpdateAssignments: (assignments, table, compilerContext) => this.standardUpdateCompiler.compileAssignments(assignments, table, compilerContext)
2154
- });
2155
- }
2156
- compileReturning(returning, ctx) {
2157
- return this.returningStrategy.compileReturning(
2158
- returning,
2159
- ctx,
2160
- (id) => this.quoteIdentifier(id)
2161
- );
2162
- }
2163
- ensureConflictColumns(clause, message) {
2164
- if (!clause.target.columns.length) throw new Error(message);
2165
- }
2166
- compileUpdateAssignments(assignments, table, ctx) {
2167
- return this.standardUpdateCompiler.compileAssignments(assignments, table, ctx);
2168
- }
2169
- compileSetTarget(column, table) {
2170
- return this.compileQualifiedColumn(column, table);
2171
- }
2172
- compileQualifiedColumn(column, table) {
2173
- const baseTableName = table.name;
2174
- const alias = table.alias;
2175
- const columnTable = column.table ?? alias ?? baseTableName;
2176
- const tableQualifier = alias && column.table === baseTableName ? alias : columnTable;
2177
- if (!tableQualifier) return this.quoteIdentifier(column.name);
2178
- return `${this.quoteIdentifier(tableQualifier)}.${this.quoteIdentifier(column.name)}`;
2179
- }
2180
- formatReturningColumns(returning) {
2181
- return this.returningStrategy.formatReturningColumns(
2182
- returning,
2183
- (id) => this.quoteIdentifier(id)
2184
- );
2185
- }
2186
- compileFrom(source, ctx) {
2187
- return this.sourceCompiler.compileFrom(source, ctx);
2188
- }
2189
- compileFunctionTable(fn9, ctx) {
2190
- return this.sourceCompiler.compileFunctionTable(fn9, ctx);
2191
- }
2192
- compileDerivedTable(table, ctx) {
2193
- return this.sourceCompiler.compileDerivedTable(table, ctx);
2194
- }
2195
- compileTableSource(table) {
2196
- return this.sourceCompiler.compileTableSource(table);
2197
- }
2198
- compileTableName(table) {
2199
- return this.sourceCompiler.compileTableName(table);
2200
- }
2201
- compileTableReference(table) {
2202
- return this.sourceCompiler.compileTableReference(table);
2203
- }
2204
- stripTrailingSemicolon(sql) {
2205
- return this.sourceCompiler.stripTrailingSemicolon(sql);
2206
- }
2207
- wrapSetOperand(sql) {
2208
- return this.sourceCompiler.wrapSetOperand(sql);
2209
- }
2210
- renderOrderByNulls(order) {
2211
- return order.nulls ? ` NULLS ${order.nulls}` : "";
2212
- }
2213
- renderOrderByCollation(order) {
2214
- return order.collation ? ` COLLATE ${order.collation}` : "";
2215
- }
1959
+ };
1960
+ const compileSelectAst = (ast, ctx) => compilerSet.select.compile(ast, ctx);
1961
+ const normalizeSelectAst = (ast) => selectAstNormalizer.normalize(ast);
1962
+ const compileSelectForExists = (ast, ctx) => {
1963
+ const normalized = normalizeSelectAst(ast);
1964
+ const full = compileSelectAst(normalized, ctx).trim().replace(/;$/, "");
1965
+ if (normalized.setOps && normalized.setOps.length > 0) {
1966
+ return `SELECT 1 FROM (${full}) AS _exists`;
1967
+ }
1968
+ const fromIndex = full.toUpperCase().indexOf(" FROM ");
1969
+ return fromIndex === -1 ? full : `SELECT 1${full.slice(fromIndex)}`;
1970
+ };
1971
+ const compileJsonPath = (node) => {
1972
+ if (!config.compileJsonPath) {
1973
+ throw new Error(`JSON Path not supported by dialect "${config.name}".`);
1974
+ }
1975
+ return config.compileJsonPath(node);
1976
+ };
1977
+ const compileFunctionOperand = (node, ctx) => {
1978
+ const compiledArgs = node.args.map((arg) => expressionRegistry2.compileOperand(arg, ctx));
1979
+ const renderer = functionStrategy.getRenderer(node.name);
1980
+ if (renderer) {
1981
+ return renderer({
1982
+ node,
1983
+ compiledArgs,
1984
+ compileOperand: (operand) => expressionRegistry2.compileOperand(operand, ctx)
1985
+ });
1986
+ }
1987
+ return `${node.name}(${compiledArgs.join(", ")})`;
1988
+ };
1989
+ expressionRegistry2 = new ExpressionCompilerRegistry({
1990
+ quoteIdentifier: config.quoteIdentifier,
1991
+ compileSelectAst,
1992
+ compileSelectForExists,
1993
+ compileJsonPath,
1994
+ compileFunctionOperand,
1995
+ describe: () => config.describe ?? config.name
1996
+ });
1997
+ const compileSetTarget = (column, table) => {
1998
+ if (config.compileSetTarget) return config.compileSetTarget(column, table);
1999
+ const columnTable = column.table ?? table.alias ?? table.name;
2000
+ const tableQualifier = table.alias && column.table === table.name ? table.alias : columnTable;
2001
+ return tableQualifier ? `${config.quoteIdentifier(tableQualifier)}.${config.quoteIdentifier(column.name)}` : config.quoteIdentifier(column.name);
2002
+ };
2003
+ let standardUpdate;
2004
+ const services = {
2005
+ getDialectName: () => config.name,
2006
+ getPaginationStrategy: () => paginationStrategy,
2007
+ getTableFunctionStrategy: () => tableFunctionStrategy,
2008
+ quoteIdentifier: config.quoteIdentifier,
2009
+ compileOperand: (node, ctx) => expressionRegistry2.compileOperand(node, ctx),
2010
+ compileExpression: (node, ctx) => expressionRegistry2.compileExpression(node, ctx),
2011
+ compileOrderingTerm: (term, ctx) => expressionRegistry2.compileOrderingTerm(term, ctx),
2012
+ normalizeSelectAst,
2013
+ compileSelectAst,
2014
+ compileReturning: (returning, ctx) => returningStrategy.compileReturning(returning, ctx, config.quoteIdentifier),
2015
+ compileUpsertClause: (ast, ctx) => upsertStrategy.compile(ast, ctx, {
2016
+ getDialectName: () => config.name,
2017
+ quoteIdentifier: config.quoteIdentifier,
2018
+ compileOperand: (node, compilerContext) => expressionRegistry2.compileOperand(node, compilerContext),
2019
+ compileExpression: (node, compilerContext) => expressionRegistry2.compileExpression(node, compilerContext),
2020
+ compileUpdateAssignments: (assignments, table, compilerContext) => standardUpdate.compileAssignments(assignments, table, compilerContext)
2021
+ }),
2022
+ compileSetTarget,
2023
+ renderOrderByNulls: (order) => config.renderOrderByNulls?.(order) ?? (order.nulls ? ` NULLS ${order.nulls}` : ""),
2024
+ renderOrderByCollation: (order) => config.renderOrderByCollation?.(order) ?? (order.collation ? ` COLLATE ${order.collation}` : "")
2025
+ };
2026
+ const sources = new StandardSqlSourceCompiler(services);
2027
+ const standardSelect = new StandardSelectCompiler(services, sources);
2028
+ const standardInsert = new StandardInsertCompiler(services, sources);
2029
+ standardUpdate = new StandardUpdateCompiler(services, sources);
2030
+ const standardDelete = new StandardDeleteCompiler(services, sources);
2031
+ const overrides = config.compilerFactory?.({ services, sources }) ?? {};
2032
+ compilerSet = {
2033
+ select: overrides.select ?? standardSelect,
2034
+ insert: overrides.insert ?? standardInsert,
2035
+ update: overrides.update ?? standardUpdate,
2036
+ delete: overrides.delete ?? standardDelete
2037
+ };
2038
+ const expressionApi = {
2039
+ registerExpressionCompiler(type, compiler) {
2040
+ expressionRegistry2.registerExpressionCompiler(type, compiler);
2041
+ },
2042
+ registerOperandCompiler(type, compiler) {
2043
+ expressionRegistry2.registerOperandCompiler(type, compiler);
2044
+ },
2045
+ compileExpression(node, ctx) {
2046
+ return expressionRegistry2.compileExpression(node, ctx);
2047
+ },
2048
+ compileOperand(node, ctx) {
2049
+ return expressionRegistry2.compileOperand(node, ctx);
2050
+ },
2051
+ compileOrderingTerm(term, ctx) {
2052
+ return expressionRegistry2.compileOrderingTerm(term, ctx);
2053
+ }
2054
+ };
2055
+ config.configureExpressions?.(expressionApi);
2056
+ const dialect = {
2057
+ quoteIdentifier: config.quoteIdentifier,
2058
+ supportsDmlReturningClause: () => config.supportsDmlReturning ?? false,
2059
+ compileSelect(ast) {
2060
+ const ctx = createCompilerContext();
2061
+ return {
2062
+ sql: terminate(compileSelectAst(normalizeSelectAst(ast), ctx)),
2063
+ params: [...ctx.params]
2064
+ };
2065
+ },
2066
+ compileInsert(ast) {
2067
+ const ctx = createCompilerContext();
2068
+ return {
2069
+ sql: terminate(compilerSet.insert.compile(ast, ctx)),
2070
+ params: [...ctx.params]
2071
+ };
2072
+ },
2073
+ compileUpdate(ast) {
2074
+ const ctx = createCompilerContext();
2075
+ return {
2076
+ sql: terminate(compilerSet.update.compile(ast, ctx)),
2077
+ params: [...ctx.params]
2078
+ };
2079
+ },
2080
+ compileDelete(ast) {
2081
+ const ctx = createCompilerContext();
2082
+ return {
2083
+ sql: terminate(compilerSet.delete.compile(ast, ctx)),
2084
+ params: [...ctx.params]
2085
+ };
2086
+ }
2087
+ };
2088
+ const runtime = {
2089
+ quoteIdentifier: config.quoteIdentifier,
2090
+ createCompilerContext,
2091
+ compileOperand: (node, ctx) => expressionRegistry2.compileOperand(node, ctx),
2092
+ compileExpression: (node, ctx) => expressionRegistry2.compileExpression(node, ctx),
2093
+ compileOrderingTerm: (term, ctx) => expressionRegistry2.compileOrderingTerm(term, ctx),
2094
+ normalizeSelectAst,
2095
+ compileSelectAst
2096
+ };
2097
+ return { dialect, runtime };
2216
2098
  };
2099
+ var createSqlDialect = (config) => composeSqlDialect(config).dialect;
2217
2100
 
2218
2101
  // src/core/dialect/postgres/functions.ts
2219
2102
  var PostgresFunctionStrategy = class extends StandardFunctionStrategy {
@@ -2376,15 +2259,15 @@ var PostgresTableFunctionStrategy = class extends StandardTableFunctionStrategy
2376
2259
  this.registerOverrides();
2377
2260
  }
2378
2261
  registerOverrides() {
2379
- this.add("ARRAY_UNNEST", ({ node, compiledArgs, quoteIdentifier }) => {
2262
+ this.add("ARRAY_UNNEST", ({ node, compiledArgs, quoteIdentifier: quoteIdentifier5 }) => {
2380
2263
  const lateral = node.lateral ?? true;
2381
2264
  const withOrd = node.withOrdinality ?? false;
2382
2265
  const base = `unnest(${compiledArgs.join(", ")})${withOrd ? " WITH ORDINALITY" : ""}`;
2383
2266
  if (node.columnAliases?.length && !node.alias) {
2384
2267
  throw new Error("tvf(ARRAY_UNNEST) with columnAliases requires an alias.");
2385
2268
  }
2386
- const alias = node.alias ? ` AS ${quoteIdentifier(node.alias)}` : "";
2387
- const cols = node.columnAliases?.length ? `(${node.columnAliases.map(quoteIdentifier).join(", ")})` : "";
2269
+ const alias = node.alias ? ` AS ${quoteIdentifier5(node.alias)}` : "";
2270
+ const cols = node.columnAliases?.length ? `(${node.columnAliases.map(quoteIdentifier5).join(", ")})` : "";
2388
2271
  return `${lateral ? "LATERAL " : ""}${base}${alias}${cols}`;
2389
2272
  });
2390
2273
  }
@@ -2449,52 +2332,68 @@ var PostgresUpsertStrategy = class {
2449
2332
  };
2450
2333
 
2451
2334
  // src/core/dialect/postgres/index.ts
2452
- var PostgresDialect = class extends SqlDialectBase {
2453
- dialect = "postgres";
2454
- procedureCompiler;
2455
- constructor() {
2456
- super({
2457
- functionStrategy: new PostgresFunctionStrategy(),
2458
- tableFunctionStrategy: new PostgresTableFunctionStrategy(),
2459
- returningStrategy: new PostgresReturningStrategy(),
2460
- upsertStrategy: new PostgresUpsertStrategy(),
2461
- supportsDmlReturning: true
2462
- });
2463
- this.procedureCompiler = new PostgresProcedureCompiler({
2464
- quoteIdentifier: (id) => this.quoteIdentifier(id),
2465
- createCompilerContext: () => this.createCompilerContext(),
2466
- compileOperand: (node, ctx) => this.compileOperand(node, ctx)
2467
- });
2468
- this.registerExpressionCompiler("BitwiseExpression", (node, ctx) => {
2469
- const left2 = this.compileOperand(node.left, ctx);
2470
- const right2 = this.compileOperand(node.right, ctx);
2471
- const operator = node.operator === "^" ? "#" : node.operator;
2472
- return `${left2} ${operator} ${right2}`;
2473
- });
2474
- this.registerOperandCompiler("BitwiseExpression", (node, ctx) => {
2475
- const left2 = this.compileOperand(node.left, ctx);
2476
- const right2 = this.compileOperand(node.right, ctx);
2477
- const operator = node.operator === "^" ? "#" : node.operator;
2478
- return `(${left2} ${operator} ${right2})`;
2479
- });
2480
- }
2335
+ var quoteIdentifier = (id) => `"${id}"`;
2336
+ var createPostgresDialect = () => {
2337
+ const composition = composeSqlDialect({
2338
+ name: "postgres",
2339
+ quoteIdentifier,
2340
+ formatPlaceholder: (index) => `$${index}`,
2341
+ functionStrategy: new PostgresFunctionStrategy(),
2342
+ tableFunctionStrategy: new PostgresTableFunctionStrategy(),
2343
+ returningStrategy: new PostgresReturningStrategy(),
2344
+ upsertStrategy: new PostgresUpsertStrategy(),
2345
+ supportsDmlReturning: true,
2346
+ compileSetTarget: (column, _table) => {
2347
+ void _table;
2348
+ return quoteIdentifier(column.name);
2349
+ },
2350
+ compileJsonPath(node) {
2351
+ const column = `${quoteIdentifier(node.column.table)}.${quoteIdentifier(node.column.name)}`;
2352
+ return `${column}->>'${node.path}'`;
2353
+ },
2354
+ configureExpressions(api) {
2355
+ api.registerExpressionCompiler("BitwiseExpression", (node, ctx) => {
2356
+ const left2 = api.compileOperand(node.left, ctx);
2357
+ const right2 = api.compileOperand(node.right, ctx);
2358
+ const operator = node.operator === "^" ? "#" : node.operator;
2359
+ return `${left2} ${operator} ${right2}`;
2360
+ });
2361
+ api.registerOperandCompiler("BitwiseExpression", (node, ctx) => {
2362
+ const left2 = api.compileOperand(node.left, ctx);
2363
+ const right2 = api.compileOperand(node.right, ctx);
2364
+ const operator = node.operator === "^" ? "#" : node.operator;
2365
+ return `(${left2} ${operator} ${right2})`;
2366
+ });
2367
+ }
2368
+ });
2369
+ const procedures = new PostgresProcedureCompiler(composition.runtime);
2370
+ return {
2371
+ ...composition.dialect,
2372
+ compileProcedureCall: (ast) => procedures.compileProcedureCall(ast)
2373
+ };
2374
+ };
2375
+ var PostgresDialect = class {
2376
+ impl = createPostgresDialect();
2481
2377
  quoteIdentifier(id) {
2482
- return `"${id}"`;
2378
+ return this.impl.quoteIdentifier(id);
2483
2379
  }
2484
- formatPlaceholder(index) {
2485
- return `$${index}`;
2380
+ supportsDmlReturningClause() {
2381
+ return this.impl.supportsDmlReturningClause();
2486
2382
  }
2487
- compileJsonPath(node) {
2488
- const column = `${this.quoteIdentifier(node.column.table)}.${this.quoteIdentifier(node.column.name)}`;
2489
- return `${column}->>'${node.path}'`;
2383
+ compileSelect(ast) {
2384
+ return this.impl.compileSelect(ast);
2490
2385
  }
2491
- /** PostgreSQL requires unqualified column names in SET clauses. */
2492
- compileSetTarget(column, _table) {
2493
- void _table;
2494
- return this.quoteIdentifier(column.name);
2386
+ compileInsert(ast) {
2387
+ return this.impl.compileInsert(ast);
2388
+ }
2389
+ compileUpdate(ast) {
2390
+ return this.impl.compileUpdate(ast);
2391
+ }
2392
+ compileDelete(ast) {
2393
+ return this.impl.compileDelete(ast);
2495
2394
  }
2496
2395
  compileProcedureCall(ast) {
2497
- return this.procedureCompiler.compileProcedureCall(ast);
2396
+ return this.impl.compileProcedureCall(ast);
2498
2397
  }
2499
2398
  };
2500
2399
 
@@ -2674,38 +2573,57 @@ var MySqlUpsertStrategy = class {
2674
2573
  };
2675
2574
 
2676
2575
  // src/core/dialect/mysql/index.ts
2677
- var MySqlDialect = class extends SqlDialectBase {
2678
- dialect = "mysql";
2679
- procedureCompiler;
2680
- constructor() {
2681
- super({
2682
- functionStrategy: new MysqlFunctionStrategy(),
2683
- upsertStrategy: new MySqlUpsertStrategy()
2684
- });
2685
- this.procedureCompiler = new MySqlProcedureCompiler({
2686
- quoteIdentifier: (id) => this.quoteIdentifier(id),
2687
- createCompilerContext: () => this.createCompilerContext(),
2688
- compileOperand: (node, ctx) => this.compileOperand(node, ctx)
2689
- });
2690
- this.registerExpressionCompiler(
2691
- "IsDistinctExpression",
2692
- (node, ctx) => {
2693
- const left2 = this.compileOperand(node.left, ctx);
2694
- const right2 = this.compileOperand(node.right, ctx);
2695
- const spaceship = `${left2} <=> ${right2}`;
2696
- return node.operator === "IS NOT DISTINCT FROM" ? spaceship : `NOT (${spaceship})`;
2697
- }
2698
- );
2699
- }
2576
+ var quoteIdentifier2 = (id) => `\`${id}\``;
2577
+ var createMySqlDialect = () => {
2578
+ const composition = composeSqlDialect({
2579
+ name: "mysql",
2580
+ quoteIdentifier: quoteIdentifier2,
2581
+ functionStrategy: new MysqlFunctionStrategy(),
2582
+ upsertStrategy: new MySqlUpsertStrategy(),
2583
+ compileJsonPath(node) {
2584
+ const column = `${quoteIdentifier2(node.column.table)}.${quoteIdentifier2(node.column.name)}`;
2585
+ return `${column}->'${node.path}'`;
2586
+ },
2587
+ configureExpressions(api) {
2588
+ api.registerExpressionCompiler(
2589
+ "IsDistinctExpression",
2590
+ (node, ctx) => {
2591
+ const left2 = api.compileOperand(node.left, ctx);
2592
+ const right2 = api.compileOperand(node.right, ctx);
2593
+ const spaceship = `${left2} <=> ${right2}`;
2594
+ return node.operator === "IS NOT DISTINCT FROM" ? spaceship : `NOT (${spaceship})`;
2595
+ }
2596
+ );
2597
+ }
2598
+ });
2599
+ const procedures = new MySqlProcedureCompiler(composition.runtime);
2600
+ return {
2601
+ ...composition.dialect,
2602
+ compileProcedureCall: (ast) => procedures.compileProcedureCall(ast)
2603
+ };
2604
+ };
2605
+ var MySqlDialect = class {
2606
+ impl = createMySqlDialect();
2700
2607
  quoteIdentifier(id) {
2701
- return `\`${id}\``;
2608
+ return this.impl.quoteIdentifier(id);
2702
2609
  }
2703
- compileJsonPath(node) {
2704
- const column = `${this.quoteIdentifier(node.column.table)}.${this.quoteIdentifier(node.column.name)}`;
2705
- return `${column}->'${node.path}'`;
2610
+ supportsDmlReturningClause() {
2611
+ return this.impl.supportsDmlReturningClause();
2612
+ }
2613
+ compileSelect(ast) {
2614
+ return this.impl.compileSelect(ast);
2615
+ }
2616
+ compileInsert(ast) {
2617
+ return this.impl.compileInsert(ast);
2618
+ }
2619
+ compileUpdate(ast) {
2620
+ return this.impl.compileUpdate(ast);
2621
+ }
2622
+ compileDelete(ast) {
2623
+ return this.impl.compileDelete(ast);
2706
2624
  }
2707
2625
  compileProcedureCall(ast) {
2708
- return this.procedureCompiler.compileProcedureCall(ast);
2626
+ return this.impl.compileProcedureCall(ast);
2709
2627
  }
2710
2628
  };
2711
2629
 
@@ -2848,15 +2766,15 @@ var SqliteFunctionStrategy = class extends StandardFunctionStrategy {
2848
2766
 
2849
2767
  // src/core/dialect/sqlite/returning.ts
2850
2768
  var SqliteReturningStrategy = class {
2851
- compileReturning(returning, _ctx, quoteIdentifier) {
2769
+ compileReturning(returning, _ctx, quoteIdentifier5) {
2852
2770
  void _ctx;
2853
2771
  if (!returning || returning.length === 0) return "";
2854
- return ` RETURNING ${this.formatReturningColumns(returning, quoteIdentifier)}`;
2772
+ return ` RETURNING ${this.formatReturningColumns(returning, quoteIdentifier5)}`;
2855
2773
  }
2856
- formatReturningColumns(returning, quoteIdentifier) {
2774
+ formatReturningColumns(returning, quoteIdentifier5) {
2857
2775
  return returning.map((column) => {
2858
- const alias = column.alias ? ` AS ${quoteIdentifier(column.alias)}` : "";
2859
- return `${quoteIdentifier(column.name)}${alias}`;
2776
+ const alias = column.alias ? ` AS ${quoteIdentifier5(column.alias)}` : "";
2777
+ return `${quoteIdentifier5(column.name)}${alias}`;
2860
2778
  }).join(", ");
2861
2779
  }
2862
2780
  };
@@ -2887,42 +2805,60 @@ var SqliteUpsertStrategy = class {
2887
2805
  };
2888
2806
 
2889
2807
  // src/core/dialect/sqlite/index.ts
2890
- var SqliteDialect = class extends SqlDialectBase {
2891
- dialect = "sqlite";
2892
- constructor() {
2893
- super({
2894
- functionStrategy: new SqliteFunctionStrategy(),
2895
- returningStrategy: new SqliteReturningStrategy(),
2896
- upsertStrategy: new SqliteUpsertStrategy(),
2897
- supportsDmlReturning: true
2898
- });
2899
- this.registerExpressionCompiler("BitwiseExpression", (node, ctx) => {
2900
- const left2 = this.compileOperand(node.left, ctx);
2901
- const right2 = this.compileOperand(node.right, ctx);
2808
+ var quoteIdentifier3 = (id) => `"${id}"`;
2809
+ var createSqliteDialect = () => composeSqlDialect({
2810
+ name: "sqlite",
2811
+ quoteIdentifier: quoteIdentifier3,
2812
+ functionStrategy: new SqliteFunctionStrategy(),
2813
+ returningStrategy: new SqliteReturningStrategy(),
2814
+ upsertStrategy: new SqliteUpsertStrategy(),
2815
+ supportsDmlReturning: true,
2816
+ compileSetTarget: (column, _table) => {
2817
+ void _table;
2818
+ return quoteIdentifier3(column.name);
2819
+ },
2820
+ compileJsonPath(node) {
2821
+ const column = `${quoteIdentifier3(node.column.table)}.${quoteIdentifier3(node.column.name)}`;
2822
+ return `json_extract(${column}, '${node.path}')`;
2823
+ },
2824
+ configureExpressions(api) {
2825
+ api.registerExpressionCompiler("BitwiseExpression", (node, ctx) => {
2826
+ const left2 = api.compileOperand(node.left, ctx);
2827
+ const right2 = api.compileOperand(node.right, ctx);
2902
2828
  if (node.operator === "^") {
2903
2829
  return `(${left2} | ${right2}) & ~(${left2} & ${right2})`;
2904
2830
  }
2905
2831
  return `${left2} ${node.operator} ${right2}`;
2906
2832
  });
2907
- this.registerOperandCompiler("BitwiseExpression", (node, ctx) => {
2908
- const left2 = this.compileOperand(node.left, ctx);
2909
- const right2 = this.compileOperand(node.right, ctx);
2833
+ api.registerOperandCompiler("BitwiseExpression", (node, ctx) => {
2834
+ const left2 = api.compileOperand(node.left, ctx);
2835
+ const right2 = api.compileOperand(node.right, ctx);
2910
2836
  if (node.operator === "^") {
2911
2837
  return `((${left2} | ${right2}) & ~(${left2} & ${right2}))`;
2912
2838
  }
2913
2839
  return `(${left2} ${node.operator} ${right2})`;
2914
2840
  });
2915
2841
  }
2842
+ }).dialect;
2843
+ var SqliteDialect = class {
2844
+ impl = createSqliteDialect();
2916
2845
  quoteIdentifier(id) {
2917
- return `"${id}"`;
2846
+ return this.impl.quoteIdentifier(id);
2918
2847
  }
2919
- compileJsonPath(node) {
2920
- const column = `${this.quoteIdentifier(node.column.table)}.${this.quoteIdentifier(node.column.name)}`;
2921
- return `json_extract(${column}, '${node.path}')`;
2848
+ supportsDmlReturningClause() {
2849
+ return this.impl.supportsDmlReturningClause();
2922
2850
  }
2923
- compileQualifiedColumn(column, _table) {
2924
- void _table;
2925
- return this.quoteIdentifier(column.name);
2851
+ compileSelect(ast) {
2852
+ return this.impl.compileSelect(ast);
2853
+ }
2854
+ compileInsert(ast) {
2855
+ return this.impl.compileInsert(ast);
2856
+ }
2857
+ compileUpdate(ast) {
2858
+ return this.impl.compileUpdate(ast);
2859
+ }
2860
+ compileDelete(ast) {
2861
+ return this.impl.compileDelete(ast);
2926
2862
  }
2927
2863
  };
2928
2864
 
@@ -3052,22 +2988,22 @@ var MssqlFunctionStrategy = class extends StandardFunctionStrategy {
3052
2988
 
3053
2989
  // src/core/dialect/mssql/output.ts
3054
2990
  var MssqlOutputStrategy = class {
3055
- compileReturning(returning, _ctx, quoteIdentifier) {
2991
+ compileReturning(returning, _ctx, quoteIdentifier5) {
3056
2992
  void _ctx;
3057
- return this.compileOutput(returning, "inserted", quoteIdentifier);
2993
+ return this.compileOutput(returning, "inserted", quoteIdentifier5);
3058
2994
  }
3059
- compileOutput(returning, prefix, quoteIdentifier) {
2995
+ compileOutput(returning, prefix, quoteIdentifier5) {
3060
2996
  if (!returning || returning.length === 0) return "";
3061
2997
  const columns = returning.map((column) => {
3062
- const alias = column.alias ? ` AS ${quoteIdentifier(column.alias)}` : "";
3063
- return `${prefix}.${quoteIdentifier(column.name)}${alias}`;
2998
+ const alias = column.alias ? ` AS ${quoteIdentifier5(column.alias)}` : "";
2999
+ return `${prefix}.${quoteIdentifier5(column.name)}${alias}`;
3064
3000
  }).join(", ");
3065
3001
  return ` OUTPUT ${columns}`;
3066
3002
  }
3067
- formatReturningColumns(returning, quoteIdentifier) {
3003
+ formatReturningColumns(returning, quoteIdentifier5) {
3068
3004
  return returning.map((column) => {
3069
- const alias = column.alias ? ` AS ${quoteIdentifier(column.alias)}` : "";
3070
- return `${quoteIdentifier(column.name)}${alias}`;
3005
+ const alias = column.alias ? ` AS ${quoteIdentifier5(column.alias)}` : "";
3006
+ return `${quoteIdentifier5(column.name)}${alias}`;
3071
3007
  }).join(", ");
3072
3008
  }
3073
3009
  };
@@ -3349,34 +3285,49 @@ var MssqlProcedureCompiler = class {
3349
3285
  };
3350
3286
 
3351
3287
  // src/core/dialect/mssql/index.ts
3352
- var SqlServerDialect = class extends SqlDialectBase {
3353
- dialect = "mssql";
3354
- procedureCompiler;
3355
- constructor() {
3356
- super({
3357
- functionStrategy: new MssqlFunctionStrategy(),
3358
- returningStrategy: new MssqlOutputStrategy(),
3359
- compilerFactory: createMssqlCompilerSet,
3360
- supportsDmlReturning: true
3361
- });
3362
- this.procedureCompiler = new MssqlProcedureCompiler({
3363
- quoteIdentifier: (id) => this.quoteIdentifier(id),
3364
- createCompilerContext: () => this.createCompilerContext(),
3365
- compileOperand: (node, ctx) => this.compileOperand(node, ctx)
3366
- });
3367
- }
3288
+ var quoteIdentifier4 = (id) => `[${id}]`;
3289
+ var createSqlServerDialect = () => {
3290
+ const composition = composeSqlDialect({
3291
+ name: "mssql",
3292
+ quoteIdentifier: quoteIdentifier4,
3293
+ formatPlaceholder: (index) => `@p${index}`,
3294
+ functionStrategy: new MssqlFunctionStrategy(),
3295
+ returningStrategy: new MssqlOutputStrategy(),
3296
+ compilerFactory: createMssqlCompilerSet,
3297
+ supportsDmlReturning: true,
3298
+ compileJsonPath(node) {
3299
+ const column = `${quoteIdentifier4(node.column.table)}.${quoteIdentifier4(node.column.name)}`;
3300
+ return `JSON_VALUE(${column}, '${node.path}')`;
3301
+ }
3302
+ });
3303
+ const procedures = new MssqlProcedureCompiler(composition.runtime);
3304
+ return {
3305
+ ...composition.dialect,
3306
+ compileProcedureCall: (ast) => procedures.compileProcedureCall(ast)
3307
+ };
3308
+ };
3309
+ var SqlServerDialect = class {
3310
+ impl = createSqlServerDialect();
3368
3311
  quoteIdentifier(id) {
3369
- return `[${id}]`;
3312
+ return this.impl.quoteIdentifier(id);
3370
3313
  }
3371
- compileJsonPath(node) {
3372
- const column = `${this.quoteIdentifier(node.column.table)}.${this.quoteIdentifier(node.column.name)}`;
3373
- return `JSON_VALUE(${column}, '${node.path}')`;
3314
+ supportsDmlReturningClause() {
3315
+ return this.impl.supportsDmlReturningClause();
3316
+ }
3317
+ compileSelect(ast) {
3318
+ return this.impl.compileSelect(ast);
3319
+ }
3320
+ compileInsert(ast) {
3321
+ return this.impl.compileInsert(ast);
3374
3322
  }
3375
- formatPlaceholder(index) {
3376
- return `@p${index}`;
3323
+ compileUpdate(ast) {
3324
+ return this.impl.compileUpdate(ast);
3325
+ }
3326
+ compileDelete(ast) {
3327
+ return this.impl.compileDelete(ast);
3377
3328
  }
3378
3329
  compileProcedureCall(ast) {
3379
- return this.procedureCompiler.compileProcedureCall(ast);
3330
+ return this.impl.compileProcedureCall(ast);
3380
3331
  }
3381
3332
  };
3382
3333
 
@@ -3387,59 +3338,33 @@ var DialectFactory = class {
3387
3338
  static ensureDefaults() {
3388
3339
  if (this.defaultsInitialized) return;
3389
3340
  this.defaultsInitialized = true;
3390
- if (!this.registry.has("postgres")) {
3391
- this.registry.set("postgres", () => new PostgresDialect());
3392
- }
3393
- if (!this.registry.has("mysql")) {
3394
- this.registry.set("mysql", () => new MySqlDialect());
3395
- }
3396
- if (!this.registry.has("sqlite")) {
3397
- this.registry.set("sqlite", () => new SqliteDialect());
3398
- }
3399
- if (!this.registry.has("mssql")) {
3400
- this.registry.set("mssql", () => new SqlServerDialect());
3401
- }
3341
+ if (!this.registry.has("postgres")) this.registry.set("postgres", createPostgresDialect);
3342
+ if (!this.registry.has("mysql")) this.registry.set("mysql", createMySqlDialect);
3343
+ if (!this.registry.has("sqlite")) this.registry.set("sqlite", createSqliteDialect);
3344
+ if (!this.registry.has("mssql")) this.registry.set("mssql", createSqlServerDialect);
3402
3345
  }
3403
- /**
3404
- * Register (or override) a dialect factory for a key.
3405
- *
3406
- * Implementations are structural: extending DialectBase/SqlDialectBase is
3407
- * optional. A composed object satisfying Dialect is a valid registration.
3408
- */
3346
+ /** Register or replace a structural dialect factory. */
3409
3347
  static register(key, factory) {
3410
3348
  this.registry.set(key, factory);
3411
3349
  }
3412
- /**
3413
- * Resolve a key into a Dialect instance.
3414
- * Throws if the key is not registered.
3415
- */
3350
+ /** Resolve a key into a new Dialect instance. */
3416
3351
  static create(key) {
3417
3352
  this.ensureDefaults();
3418
3353
  const factory = this.registry.get(key);
3419
3354
  if (!factory) {
3420
3355
  throw new Error(
3421
- `Dialect "${String(
3422
- key
3423
- )}" is not registered. Use DialectFactory.register(...) to register it.`
3356
+ `Dialect "${String(key)}" is not registered. Use DialectFactory.register(...) to register it.`
3424
3357
  );
3425
3358
  }
3426
3359
  return factory();
3427
3360
  }
3428
- /**
3429
- * Clear all registrations (mainly for tests).
3430
- * Built-ins will be re-registered lazily on the next create().
3431
- */
3361
+ /** Clear registrations; built-ins are restored lazily on the next create(). */
3432
3362
  static clear() {
3433
3363
  this.registry.clear();
3434
3364
  this.defaultsInitialized = false;
3435
3365
  }
3436
3366
  };
3437
- var resolveDialectInput = (dialect) => {
3438
- if (typeof dialect === "string") {
3439
- return DialectFactory.create(dialect);
3440
- }
3441
- return dialect;
3442
- };
3367
+ var resolveDialectInput = (dialect) => typeof dialect === "string" ? DialectFactory.create(dialect) : dialect;
3443
3368
 
3444
3369
  // src/core/ast/builders.ts
3445
3370
  var isColumnNode = (col2) => "type" in col2 && col2.type === "Column";
@@ -21839,7 +21764,6 @@ export {
21839
21764
  DefaultMorphToReference,
21840
21765
  DefaultTypeStrategy,
21841
21766
  DeleteQueryBuilder,
21842
- DialectBase,
21843
21767
  DialectFactory,
21844
21768
  DomainEventBus,
21845
21769
  Email,
@@ -21885,7 +21809,6 @@ export {
21885
21809
  RelationKinds,
21886
21810
  STANDARD_COLUMN_TYPES,
21887
21811
  SelectQueryBuilder,
21888
- SqlDialectBase,
21889
21812
  SqlServerDialect,
21890
21813
  SqliteDialect,
21891
21814
  SqliteReturningStrategy,
@@ -21967,6 +21890,7 @@ export {
21967
21890
  columnToOpenApiSchema,
21968
21891
  columnTypeToOpenApiFormat,
21969
21892
  columnTypeToOpenApiType,
21893
+ composeSqlDialect,
21970
21894
  computePaginationMetadata,
21971
21895
  computeSchemaHash,
21972
21896
  concat,
@@ -21986,11 +21910,16 @@ export {
21986
21910
  createExecutorFromQueryRunner,
21987
21911
  createMssqlCompilerSet,
21988
21912
  createMssqlExecutor,
21913
+ createMySqlDialect,
21989
21914
  createMysqlExecutor,
21990
21915
  createPooledExecutorFactory,
21916
+ createPostgresDialect,
21991
21917
  createPostgresExecutor,
21992
21918
  createQueryLoggingExecutor,
21993
21919
  createRef,
21920
+ createSqlDialect,
21921
+ createSqlServerDialect,
21922
+ createSqliteDialect,
21994
21923
  createSqliteExecutor,
21995
21924
  createTediousExecutor,
21996
21925
  createTediousMssqlClient,