@memberjunction/sql-dialect 6.2.0-edge.6 → 6.2.0-edge.8

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 (86) hide show
  1. package/README.md +280 -91
  2. package/dist/dialectFactory.d.ts +34 -14
  3. package/dist/dialectFactory.d.ts.map +1 -1
  4. package/dist/dialectFactory.js +101 -25
  5. package/dist/dialectFactory.js.map +1 -1
  6. package/dist/dialects/ansi.d.ts +55 -0
  7. package/dist/dialects/ansi.d.ts.map +1 -0
  8. package/dist/dialects/ansi.js +136 -0
  9. package/dist/dialects/ansi.js.map +1 -0
  10. package/dist/dialects/baseSchemaDDL.d.ts +78 -0
  11. package/dist/dialects/baseSchemaDDL.d.ts.map +1 -0
  12. package/dist/dialects/baseSchemaDDL.js +63 -0
  13. package/dist/dialects/baseSchemaDDL.js.map +1 -0
  14. package/dist/dialects/databricksQueryDialect.d.ts +41 -0
  15. package/dist/dialects/databricksQueryDialect.d.ts.map +1 -0
  16. package/dist/dialects/databricksQueryDialect.js +103 -0
  17. package/dist/dialects/databricksQueryDialect.js.map +1 -0
  18. package/dist/dialects/mysqlQueryDialect.d.ts +46 -0
  19. package/dist/dialects/mysqlQueryDialect.d.ts.map +1 -0
  20. package/dist/dialects/mysqlQueryDialect.js +117 -0
  21. package/dist/dialects/mysqlQueryDialect.js.map +1 -0
  22. package/dist/dialects/oracleQueryDialect.d.ts +42 -0
  23. package/dist/dialects/oracleQueryDialect.d.ts.map +1 -0
  24. package/dist/dialects/oracleQueryDialect.js +92 -0
  25. package/dist/dialects/oracleQueryDialect.js.map +1 -0
  26. package/dist/dialects/postgresqlSchemaDDL.d.ts +112 -0
  27. package/dist/dialects/postgresqlSchemaDDL.d.ts.map +1 -0
  28. package/dist/dialects/postgresqlSchemaDDL.js +590 -0
  29. package/dist/dialects/postgresqlSchemaDDL.js.map +1 -0
  30. package/dist/dialects/snowflakeQueryDialect.d.ts +41 -0
  31. package/dist/dialects/snowflakeQueryDialect.d.ts.map +1 -0
  32. package/dist/dialects/snowflakeQueryDialect.js +94 -0
  33. package/dist/dialects/snowflakeQueryDialect.js.map +1 -0
  34. package/dist/dialects/sqlServerSchemaDDL.d.ts +83 -0
  35. package/dist/dialects/sqlServerSchemaDDL.d.ts.map +1 -0
  36. package/dist/dialects/sqlServerSchemaDDL.js +507 -0
  37. package/dist/dialects/sqlServerSchemaDDL.js.map +1 -0
  38. package/dist/facets/dialectBinding.d.ts +26 -0
  39. package/dist/facets/dialectBinding.d.ts.map +1 -0
  40. package/dist/facets/dialectBinding.js +2 -0
  41. package/dist/facets/dialectBinding.js.map +1 -0
  42. package/dist/facets/dialectGrammar.d.ts +82 -0
  43. package/dist/facets/dialectGrammar.d.ts.map +1 -0
  44. package/dist/facets/dialectGrammar.js +2 -0
  45. package/dist/facets/dialectGrammar.js.map +1 -0
  46. package/dist/facets/dialectKey.d.ts +9 -0
  47. package/dist/facets/dialectKey.d.ts.map +1 -0
  48. package/dist/facets/dialectKey.js +2 -0
  49. package/dist/facets/dialectKey.js.map +1 -0
  50. package/dist/facets/dialectLexicalRules.d.ts +102 -0
  51. package/dist/facets/dialectLexicalRules.d.ts.map +1 -0
  52. package/dist/facets/dialectLexicalRules.js +2 -0
  53. package/dist/facets/dialectLexicalRules.js.map +1 -0
  54. package/dist/facets/dialectSchemaDDL.d.ts +213 -0
  55. package/dist/facets/dialectSchemaDDL.d.ts.map +1 -0
  56. package/dist/facets/dialectSchemaDDL.js +2 -0
  57. package/dist/facets/dialectSchemaDDL.js.map +1 -0
  58. package/dist/facets/dialectTypes.d.ts +31 -0
  59. package/dist/facets/dialectTypes.d.ts.map +1 -0
  60. package/dist/facets/dialectTypes.js +2 -0
  61. package/dist/facets/dialectTypes.js.map +1 -0
  62. package/dist/facets/dialectWriter.d.ts +59 -0
  63. package/dist/facets/dialectWriter.d.ts.map +1 -0
  64. package/dist/facets/dialectWriter.js +2 -0
  65. package/dist/facets/dialectWriter.js.map +1 -0
  66. package/dist/index.d.ts +21 -5
  67. package/dist/index.d.ts.map +1 -1
  68. package/dist/index.js +13 -4
  69. package/dist/index.js.map +1 -1
  70. package/dist/postgresqlDialect.d.ts +57 -152
  71. package/dist/postgresqlDialect.d.ts.map +1 -1
  72. package/dist/postgresqlDialect.js +110 -683
  73. package/dist/postgresqlDialect.js.map +1 -1
  74. package/dist/queryDialect.d.ts +42 -0
  75. package/dist/queryDialect.d.ts.map +1 -0
  76. package/dist/queryDialect.js +25 -0
  77. package/dist/queryDialect.js.map +1 -0
  78. package/dist/sqlDialect.d.ts +121 -212
  79. package/dist/sqlDialect.d.ts.map +1 -1
  80. package/dist/sqlDialect.js +710 -29
  81. package/dist/sqlDialect.js.map +1 -1
  82. package/dist/sqlServerDialect.d.ts +54 -120
  83. package/dist/sqlServerDialect.d.ts.map +1 -1
  84. package/dist/sqlServerDialect.js +124 -594
  85. package/dist/sqlServerDialect.js.map +1 -1
  86. package/package.json +4 -2
@@ -1,4 +1,13 @@
1
- import { DataTypeMap, MappedType } from './dataTypeMap.js';
1
+ import { MappedType } from './dataTypeMap.js';
2
+ import type { DataTypeMap } from './dataTypeMap.js';
3
+ import { QueryDialect } from './queryDialect.js';
4
+ import type { DialectKey } from './facets/dialectKey.js';
5
+ import type { DialectTypes } from './facets/dialectTypes.js';
6
+ import type { DialectBinding } from './facets/dialectBinding.js';
7
+ import type { LimitClauseResult, DateAddUnit } from './facets/dialectWriter.js';
8
+ import type { DialectSchemaDDL, SchemaIntrospectionSQL, ColumnDDLOptions, AlterColumnOptions, TriggerOptions, IndexOptions, ResolveTypeOptions } from './facets/dialectSchemaDDL.js';
9
+ export type { LimitClauseResult } from './facets/dialectWriter.js';
10
+ export type { SchemaFieldType, ResolveTypeOptions, SchemaIntrospectionSQL, ColumnDDLOptions, AlterColumnOptions, TriggerOptions, IndexOptions, } from './facets/dialectSchemaDDL.js';
2
11
  /**
3
12
  * Canonical database-platform value used across MJ. Single source of truth —
4
13
  * config validation, env-var parsing, and runtime branching all compare
@@ -10,118 +19,6 @@ import { DataTypeMap, MappedType } from './dataTypeMap.js';
10
19
  * imports it from here (or from core, which re-exports for back-compat).
11
20
  */
12
21
  export type DatabasePlatform = 'sqlserver' | 'postgresql';
13
- /**
14
- * Abstract field type used by SchemaEngine to describe columns
15
- * in a platform-agnostic way before DDL generation.
16
- */
17
- export type SchemaFieldType = 'string' | 'text' | 'integer' | 'bigint' | 'decimal' | 'boolean' | 'datetime' | 'date' | 'uuid' | 'json' | 'float' | 'time';
18
- /**
19
- * Options for resolving an abstract schema type to a concrete SQL type.
20
- */
21
- export interface ResolveTypeOptions {
22
- /** Abstract type (e.g., 'string', 'integer', 'boolean'). */
23
- type: SchemaFieldType;
24
- /** Max length for string types. */
25
- maxLength?: number;
26
- /** Precision for decimal types. */
27
- precision?: number;
28
- /** Scale for decimal types. */
29
- scale?: number;
30
- }
31
- /**
32
- * Result from limitClause() — SQL Server uses a prefix (TOP n) while
33
- * PostgreSQL uses a suffix (LIMIT n OFFSET m).
34
- */
35
- export interface LimitClauseResult {
36
- /** SQL placed between SELECT and the column list (e.g., "TOP 10") */
37
- prefix: string;
38
- /** SQL placed after the ORDER BY / WHERE clause (e.g., "LIMIT 10 OFFSET 20") */
39
- suffix: string;
40
- }
41
- /**
42
- * Schema introspection queries for a given database platform.
43
- * Each dialect provides platform-specific catalog queries.
44
- */
45
- export interface SchemaIntrospectionSQL {
46
- /** Query that returns all user tables in a schema */
47
- listTables: string;
48
- /** Query that returns all columns for a given table */
49
- listColumns: string;
50
- /** Query that returns constraints (PK, UNIQUE, CHECK) */
51
- listConstraints: string;
52
- /** Query that returns foreign key relationships */
53
- listForeignKeys: string;
54
- /** Query that returns indexes */
55
- listIndexes: string;
56
- /** Template for checking if a database object exists */
57
- objectExists: string;
58
- }
59
- /**
60
- * Options for generating a column definition in DDL.
61
- */
62
- export interface ColumnDDLOptions {
63
- /** Column name (unquoted — the dialect will quote it). */
64
- name: string;
65
- /** Full SQL type string (e.g., "NVARCHAR(255)", "INTEGER", "TIMESTAMPTZ"). */
66
- sqlType: string;
67
- /** Whether the column allows NULL values. */
68
- nullable: boolean;
69
- /** Optional default value expression (e.g., "'Active'", "GETUTCDATE()"). */
70
- defaultValue?: string;
71
- }
72
- /**
73
- * Options for ALTER TABLE column modification.
74
- */
75
- export interface AlterColumnOptions {
76
- /** Column name (unquoted). */
77
- columnName: string;
78
- /** New SQL type string. */
79
- newType: string;
80
- /** New nullability. */
81
- newNullable: boolean;
82
- }
83
- /**
84
- * Options for generating trigger DDL.
85
- */
86
- export interface TriggerOptions {
87
- /** Schema name */
88
- schema: string;
89
- /** Table name the trigger is on */
90
- tableName: string;
91
- /** Trigger name */
92
- triggerName: string;
93
- /** Timing: BEFORE, AFTER, or INSTEAD OF */
94
- timing: 'BEFORE' | 'AFTER' | 'INSTEAD OF';
95
- /** Events that fire the trigger */
96
- events: ('INSERT' | 'UPDATE' | 'DELETE')[];
97
- /** The trigger body SQL */
98
- body: string;
99
- /** For PostgreSQL: name of the trigger function */
100
- functionName?: string;
101
- /** Whether the trigger fires FOR EACH ROW or FOR EACH STATEMENT */
102
- forEach?: 'ROW' | 'STATEMENT';
103
- }
104
- /**
105
- * Options for generating index DDL.
106
- */
107
- export interface IndexOptions {
108
- /** Schema name */
109
- schema: string;
110
- /** Table name */
111
- tableName: string;
112
- /** Index name */
113
- indexName: string;
114
- /** Columns to index */
115
- columns: string[];
116
- /** Whether this is a unique index */
117
- unique?: boolean;
118
- /** Index method (btree, gin, gist, hash — PostgreSQL specific, ignored for SQL Server) */
119
- method?: string;
120
- /** WHERE clause for partial indexes (PostgreSQL only) */
121
- where?: string;
122
- /** INCLUDE columns (SQL Server covering index) */
123
- includeColumns?: string[];
124
- }
125
22
  /**
126
23
  * Minimal dialect interface consumed by `@memberjunction/sql-parser`.
127
24
  *
@@ -129,8 +26,8 @@ export interface IndexOptions {
129
26
  * {@link SQLDialect} class implements this interface plus 80+ additional
130
27
  * methods for DDL/DML generation, data type mapping, etc.
131
28
  *
132
- * When adding a new database platform, implement at minimum this interface
133
- * for parser support. Implement the full `SQLDialect` for complete MJ support.
29
+ * @deprecated Use {@link ParserDialect} (a dialect's key and its lexical and grammar facets) or
30
+ * a {@link QueryDialect}. {@link SQLDialect} still satisfies this interface.
134
31
  */
135
32
  export interface SQLParserDialect {
136
33
  /** node-sql-parser dialect string (e.g., 'TransactSQL', 'PostgresQL', 'MySQL') */
@@ -159,34 +56,49 @@ export interface SQLParserDialect {
159
56
  * them.
160
57
  */
161
58
  CallerSQLForbiddenFunctions: readonly string[];
59
+ /**
60
+ * Upper-case keywords that start a new statement wherever they appear as a bare word at the top
61
+ * level of another one, because the platform needs no separator between statements; empty or
62
+ * absent when statements must be separated. SQL Server: the statement keywords; PostgreSQL: none.
63
+ */
64
+ UnseparatedStatementKeywords?: readonly string[];
162
65
  }
163
66
  /**
164
- * Abstract base class for SQL dialect implementations.
67
+ * Abstract base class for the dialects of the platforms MJ itself runs on.
165
68
  *
166
- * Encapsulates ALL database-specific SQL syntax patterns into a single,
167
- * testable abstraction. This is a pure string/logic layer with zero
168
- * database driver dependencies.
69
+ * A {@link QueryDialect} (lexical rules, grammar facts, writer, types, binding) plus the
70
+ * {@link DDL} facet MJ needs to create and run its own schema. Every member below is kept for
71
+ * existing callers and delegates to one of the facets. This is a pure string/logic layer with
72
+ * zero database driver dependencies.
169
73
  */
170
- export declare abstract class SQLDialect implements SQLParserDialect {
74
+ export declare abstract class SQLDialect extends QueryDialect implements SQLParserDialect {
171
75
  /**
172
76
  * The platform key identifying this dialect.
173
77
  */
174
78
  abstract get PlatformKey(): DatabasePlatform;
79
+ /** The dialect key, which for a platform dialect is its {@link PlatformKey}. */
80
+ get Key(): DialectKey;
81
+ /** SQL type-name sets. */
82
+ abstract get Types(): DialectTypes;
83
+ /** Driver binding rules. */
84
+ abstract get Binding(): DialectBinding;
85
+ /** DDL, stored-procedure, migration, introspection and transaction SQL. */
86
+ abstract get DDL(): DialectSchemaDDL;
175
87
  /**
176
88
  * Returns the dialect name used by node-sql-parser for AST parsing.
177
89
  * SQL Server: 'TransactSQL', PostgreSQL: 'PostgresQL', etc.
178
90
  */
179
- abstract get ParserDialect(): string;
91
+ get ParserDialect(): string;
180
92
  /**
181
93
  * Quotes a database identifier (table name, column name, etc.).
182
94
  * SQL Server: [name], PostgreSQL: "name"
183
95
  */
184
- abstract QuoteIdentifier(name: string): string;
96
+ QuoteIdentifier(name: string): string;
185
97
  /**
186
98
  * Produces a schema-qualified object reference.
187
99
  * SQL Server: [schema].[object], PostgreSQL: schema."object"
188
100
  */
189
- abstract QuoteSchema(schema: string, object: string): string;
101
+ QuoteSchema(schema: string, object: string): string;
190
102
  /**
191
103
  * Quotes a column alias used in `SELECT ... AS <alias>`. SQL Server is
192
104
  * case-insensitive and accepts a bare identifier; PostgreSQL folds
@@ -194,7 +106,7 @@ export declare abstract class SQLDialect implements SQLParserDialect {
194
106
  * caller cares about preserving case (e.g. matching a TypeScript property
195
107
  * name in the result row).
196
108
  */
197
- abstract QuoteColumnAlias(aliasName: string): string;
109
+ QuoteColumnAlias(aliasName: string): string;
198
110
  /**
199
111
  * Canonicalizes a SCHEMA name to the form the platform actually stores when
200
112
  * the name appears UNQUOTED in DDL. PostgreSQL folds unquoted identifiers to
@@ -204,13 +116,12 @@ export declare abstract class SQLDialect implements SQLParserDialect {
204
116
  * aligned with what unquoted migration DDL produces — so a mixed-case schema
205
117
  * name can't split into two physical schemas (one quoted-mixed, one folded-lowercase).
206
118
  */
207
- abstract CanonicalSchemaName(name: string): string;
119
+ CanonicalSchemaName(name: string): string;
208
120
  /**
209
121
  * Quotes a value as a SQL string literal. Both SQL Server and PostgreSQL
210
- * use single quotes with `''` doubling to escape internal apostrophes —
211
- * this is concrete in the base class so callers don't reinvent the
212
- * `value.replace(/'/g, "''")` pattern. Subclasses may override if a
213
- * future dialect needs a different escape rule.
122
+ * use single quotes with `''` doubling to escape internal apostrophes.
123
+ * Use this instead of reinventing the `value.replace(/'/g, "''")` pattern;
124
+ * the dialect's writer owns the escape rule.
214
125
  */
215
126
  QuoteStringLiteral(value: string): string;
216
127
  /**
@@ -218,7 +129,7 @@ export declare abstract class SQLDialect implements SQLParserDialect {
218
129
  * `''` when a plain literal does. SQL Server: `N` when the text has characters outside ASCII,
219
130
  * which a plain literal would lose to the database code page. PostgreSQL: always `''`.
220
131
  */
221
- abstract StringLiteralPrefix(text: string): string;
132
+ StringLiteralPrefix(text: string): string;
222
133
  /**
223
134
  * Escapes the characters a `LIKE` pattern treats specially, so `text` matches literally with
224
135
  * the platform's default escape rules (no `ESCAPE` clause). Quotes are not escaped here; the
@@ -226,23 +137,23 @@ export declare abstract class SQLDialect implements SQLParserDialect {
226
137
  * SQL Server: `[`, `%` and `_` become `[[]`, `[%]` and `[_]`. PostgreSQL: `\`, `%` and `_`
227
138
  * are escaped with a backslash.
228
139
  */
229
- abstract EscapeLikePattern(text: string): string;
140
+ EscapeLikePattern(text: string): string;
230
141
  /**
231
142
  * The value to bind for a boolean query parameter. SQL Server: `1` / `0` (BIT),
232
143
  * PostgreSQL: `true` / `false`.
233
144
  */
234
- abstract BooleanParameterValue(value: boolean): boolean | number;
145
+ BooleanParameterValue(value: boolean): boolean | number;
235
146
  /**
236
147
  * Returns pagination SQL fragments.
237
148
  * SQL Server uses TOP (prefix) or OFFSET/FETCH (suffix).
238
149
  * PostgreSQL uses LIMIT/OFFSET (suffix).
239
150
  */
240
- abstract LimitClause(limit: number, offset?: number): LimitClauseResult;
151
+ LimitClause(limit: number, offset?: number): LimitClauseResult;
241
152
  /**
242
153
  * Returns a boolean literal for the platform.
243
154
  * SQL Server: "1"/"0", PostgreSQL: "true"/"false"
244
155
  */
245
- abstract BooleanLiteral(value: boolean): string;
156
+ BooleanLiteral(value: boolean): string;
246
157
  /**
247
158
  * Returns the SQL type token for a boolean parameter in a stored-procedure /
248
159
  * function signature. Used by codegen when emitting tolerant-SP `_Clear`
@@ -255,12 +166,12 @@ export declare abstract class SQLDialect implements SQLParserDialect {
255
166
  * that PG rejected as `operator does not exist: boolean = integer` when
256
167
  * the generated CASE compared a `bit`-declared parameter with `= 1`.
257
168
  */
258
- abstract BooleanParameterType(): string;
169
+ BooleanParameterType(): string;
259
170
  /**
260
171
  * Returns the current UTC timestamp expression.
261
172
  * SQL Server: GETUTCDATE(), PostgreSQL: NOW() AT TIME ZONE 'UTC'
262
173
  */
263
- abstract CurrentTimestampUTC(): string;
174
+ CurrentTimestampUTC(): string;
264
175
  /**
265
176
  * Wraps a single DML statement so the number of rows it affected comes back as a one-row,
266
177
  * one-column result set — the portable way to read an affected-row count without relying on a
@@ -272,7 +183,7 @@ export declare abstract class SQLDialect implements SQLParserDialect {
272
183
  * `dmlStatement` must be exactly one INSERT/UPDATE/DELETE and carry no trailing semicolon:
273
184
  * the PostgreSQL form is a CTE, which cannot wrap a statement batch.
274
185
  */
275
- abstract AffectedRowCountSQL(dmlStatement: string, alias: string): string;
186
+ AffectedRowCountSQL(dmlStatement: string, alias: string): string;
276
187
  /**
277
188
  * Wraps an expression in the dialect's lowercase function — used for
278
189
  * case-insensitive comparison when authoring filters that must work on
@@ -315,9 +226,9 @@ export declare abstract class SQLDialect implements SQLParserDialect {
315
226
  */
316
227
  get PromptGuidance(): string;
317
228
  /** SQL type names this dialect uses for boolean columns. */
318
- abstract get BooleanTypeNames(): readonly string[];
229
+ get BooleanTypeNames(): readonly string[];
319
230
  /** SQL type names this dialect uses for variable-length character / text columns. */
320
- abstract get StringTypeNames(): readonly string[];
231
+ get StringTypeNames(): readonly string[];
321
232
  /**
322
233
  * Subset of {@link StringTypeNames} that represents **fixed-width** /
323
234
  * space-padded character types. SQL Server `char`/`nchar` and PostgreSQL
@@ -329,7 +240,7 @@ export declare abstract class SQLDialect implements SQLParserDialect {
329
240
  * Used by `BaseEntity` to rtrim padding on load so dirty-checks and
330
241
  * downstream consumers see the logical value, not the storage form.
331
242
  */
332
- abstract get FixedWidthStringTypeNames(): readonly string[];
243
+ get FixedWidthStringTypeNames(): readonly string[];
333
244
  /**
334
245
  * Maximum string length usable in an INDEX KEY column (PRIMARY KEY / UNIQUE constraint) on this
335
246
  * dialect. A PK string column wider than this can't be indexed, so callers (e.g. the integration
@@ -358,37 +269,36 @@ export declare abstract class SQLDialect implements SQLParserDialect {
358
269
  * their full size. Only meaningful for dialects that report a {@link MaxInRowSizeBytes}.
359
270
  * Default: 24 (a conservative off-row-pointer floor).
360
271
  */
361
- EstimateInRowBytes(_rawSqlType: string): number;
272
+ EstimateInRowBytes(rawSqlType: string): number;
362
273
  /** SQL type names this dialect uses for date / time / timestamp columns. */
363
- abstract get DateTypeNames(): readonly string[];
274
+ get DateTypeNames(): readonly string[];
364
275
  /** SQL type names this dialect uses for integer columns (int, bigint, smallint, …). */
365
- abstract get IntegerTypeNames(): readonly string[];
276
+ get IntegerTypeNames(): readonly string[];
366
277
  /** SQL type names this dialect uses for floating-point / decimal columns. */
367
- abstract get FloatTypeNames(): readonly string[];
278
+ get FloatTypeNames(): readonly string[];
368
279
  /** SQL type names this dialect uses for UUID / uniqueidentifier columns. */
369
- abstract get UuidTypeNames(): readonly string[];
280
+ get UuidTypeNames(): readonly string[];
370
281
  /** SQL type names this dialect uses for binary blob columns (image, bytea, varbinary). */
371
- abstract get BinaryTypeNames(): readonly string[];
282
+ get BinaryTypeNames(): readonly string[];
372
283
  /** SQL type names this dialect uses for JSON / XML structured columns. */
373
- abstract get JsonTypeNames(): readonly string[];
284
+ get JsonTypeNames(): readonly string[];
374
285
  /** SQL type names this dialect uses for fixed-precision currency columns. */
375
- abstract get CurrencyTypeNames(): readonly string[];
286
+ get CurrencyTypeNames(): readonly string[];
376
287
  /** SQL type names this dialect uses for interval / duration columns. */
377
- abstract get IntervalTypeNames(): readonly string[];
288
+ get IntervalTypeNames(): readonly string[];
378
289
  /** SQL type names this dialect uses for network address columns (inet, cidr, …). */
379
- abstract get NetworkTypeNames(): readonly string[];
290
+ get NetworkTypeNames(): readonly string[];
380
291
  /**
381
292
  * Returns a new UUID generation expression.
382
293
  * SQL Server: NEWID(), PostgreSQL: gen_random_uuid()
383
294
  */
384
- abstract NewUUID(): string;
295
+ NewUUID(): string;
385
296
  /**
386
297
  * Returns the platform's n-ary null-coalescing expression. SQL Server and
387
- * PostgreSQL both spell this `COALESCE(...)`, but a future dialect could
388
- * use a different keyword — abstract on purpose so each dialect must
389
- * declare its own form rather than inheriting an opinionated default.
298
+ * PostgreSQL both spell this `COALESCE(...)`; the dialect's writer owns
299
+ * the spelling.
390
300
  */
391
- abstract Coalesce(expr: string, fallback: string): string;
301
+ Coalesce(expr: string, fallback: string): string;
392
302
  /**
393
303
  * Returns the dialect's literal representation of NULL as it would
394
304
  * appear in generated SQL (e.g. as the result of a default-value
@@ -410,19 +320,19 @@ export declare abstract class SQLDialect implements SQLParserDialect {
410
320
  * SQL Server: `@MyName`, PostgreSQL functions: `p_my_name`.
411
321
  * Codegen should call this rather than hard-coding `'@' + name`.
412
322
  */
413
- abstract ParameterRef(name: string): string;
323
+ ParameterRef(name: string): string;
414
324
  /**
415
325
  * Returns the default-value clause appended to a parameter declaration.
416
326
  * SQL Server: ` = NULL` (or ` = 0`, etc.), PostgreSQL: ` DEFAULT NULL`.
417
327
  * `value` should be a SQL literal already formatted by the caller (e.g.
418
328
  * the dialect's NullLiteral, a quoted string, a numeric literal).
419
329
  */
420
- abstract ParameterDefault(value: string): string;
330
+ ParameterDefault(value: string): string;
421
331
  /**
422
332
  * Returns a CAST-to-text expression.
423
333
  * SQL Server: CAST(expr AS NVARCHAR(MAX)), PostgreSQL: CAST(expr AS TEXT)
424
334
  */
425
- abstract CastToText(expr: string): string;
335
+ CastToText(expr: string): string;
426
336
  /**
427
337
  * Returns a CAST to a bounded-width string type. Used when the result
428
338
  * needs to be comparable against an indexed column (SQL Server cannot
@@ -439,7 +349,7 @@ export declare abstract class SQLDialect implements SQLParserDialect {
439
349
  * Returns a CAST-to-UUID expression.
440
350
  * SQL Server: CAST(expr AS UNIQUEIDENTIFIER), PostgreSQL: CAST(expr AS UUID)
441
351
  */
442
- abstract CastToUUID(expr: string): string;
352
+ CastToUUID(expr: string): string;
443
353
  /**
444
354
  * Returns the empty-GUID sentinel literal
445
355
  * (`00000000-0000-0000-0000-000000000000`) formatted for use in a
@@ -454,32 +364,32 @@ export declare abstract class SQLDialect implements SQLParserDialect {
454
364
  * SQL Server: OUTPUT INSERTED.col1, INSERTED.col2
455
365
  * PostgreSQL: RETURNING col1, col2
456
366
  */
457
- abstract ReturnInsertedClause(columns?: string[]): string;
367
+ ReturnInsertedClause(columns?: string[]): string;
458
368
  /**
459
369
  * Returns the auto-increment PK expression for DDL.
460
370
  * SQL Server: IDENTITY(1,1), PostgreSQL: GENERATED ALWAYS AS IDENTITY
461
371
  */
462
- abstract AutoIncrementPKExpression(): string;
372
+ AutoIncrementPKExpression(): string;
463
373
  /**
464
374
  * Returns the default expression for a UUID primary key.
465
375
  * SQL Server: NEWSEQUENTIALID(), PostgreSQL: gen_random_uuid()
466
376
  */
467
- abstract UUIDPKDefault(): string;
377
+ UUIDPKDefault(): string;
468
378
  /**
469
379
  * Returns the expression to get the last inserted identity value.
470
380
  * SQL Server: SCOPE_IDENTITY(), PostgreSQL: lastval()
471
381
  */
472
- abstract ScopeIdentityExpression(): string;
382
+ ScopeIdentityExpression(): string;
473
383
  /**
474
384
  * Returns the row count variable/expression for the last statement.
475
385
  * SQL Server: @@ROWCOUNT, PostgreSQL: (via GET DIAGNOSTICS or FOUND)
476
386
  */
477
- abstract RowCountExpression(): string;
387
+ RowCountExpression(): string;
478
388
  /**
479
389
  * Returns the batch separator for the platform.
480
390
  * SQL Server: "GO", PostgreSQL: "" (none needed)
481
391
  */
482
- abstract BatchSeparator(): string;
392
+ BatchSeparator(): string;
483
393
  /**
484
394
  * Splits an oversized SQL batch into individual statements on `;`+EOL
485
395
  * boundaries so a caller (e.g. the RSU migration executor) can re-group
@@ -501,66 +411,68 @@ export declare abstract class SQLDialect implements SQLParserDialect {
501
411
  * @param schema - Schema name
502
412
  * @param name - Object name
503
413
  */
504
- abstract ExistenceCheckSQL(objectType: string, schema: string, name: string): string;
414
+ ExistenceCheckSQL(objectType: string, schema: string, name: string): string;
505
415
  /**
506
416
  * Whether the platform supports CREATE OR REPLACE for a given object type.
507
417
  * PostgreSQL supports it for FUNCTION, VIEW. SQL Server does not.
508
418
  */
509
- abstract CreateOrReplaceSupported(objectType: string): boolean;
419
+ CreateOrReplaceSupported(objectType: string): boolean;
510
420
  /**
511
421
  * Returns a full-text search predicate expression.
512
422
  * SQL Server: CONTAINS(column, searchTerm)
513
423
  * PostgreSQL: column @@ plainto_tsquery('english', searchTerm)
514
424
  */
515
- abstract FullTextSearchPredicate(column: string, searchTerm: string): string;
425
+ FullTextSearchPredicate(column: string, searchTerm: string): string;
516
426
  /**
517
427
  * Returns DDL to create a full-text index.
518
428
  * SQL Server: FULLTEXT CATALOG + FULLTEXT INDEX
519
429
  * PostgreSQL: tsvector column + GIN index
520
430
  */
521
- abstract FullTextIndexDDL(table: string, columns: string[], catalog?: string): string;
431
+ FullTextIndexDDL(table: string, columns: string[], catalog?: string): string;
522
432
  /**
523
433
  * Returns the recursive CTE syntax keyword.
524
434
  * SQL Server: "WITH", PostgreSQL: "WITH RECURSIVE"
525
435
  */
526
- abstract RecursiveCTESyntax(): string;
436
+ RecursiveCTESyntax(): string;
527
437
  /**
528
438
  * Whether the platform allows ORDER BY inside CTE definitions without
529
439
  * TOP, OFFSET, or FOR XML.
530
440
  * SQL Server: false (ORDER BY in CTEs is illegal without TOP/OFFSET/FOR XML)
531
441
  * PostgreSQL: true (ORDER BY in CTEs is always legal)
532
442
  */
533
- abstract get AllowsOrderByInCTE(): boolean;
443
+ get AllowsOrderByInCTE(): boolean;
534
444
  /**
535
445
  * Default ORDER BY expression for paging when no user-specified ORDER BY exists.
536
446
  * SQL Server: '(SELECT NULL)', PostgreSQL: '1'
537
447
  */
538
- abstract get DefaultPagingOrderBy(): string;
448
+ get DefaultPagingOrderBy(): string;
539
449
  /**
540
450
  * The ORDER BY expression for paging a set operation (`UNION` / `INTERSECT` / `EXCEPT`) or a
541
451
  * `SELECT DISTINCT` that has no ORDER BY of its own, on a platform that only accepts select-list
542
452
  * items there. `null` when {@link DefaultPagingOrderBy} is accepted for those shapes too.
543
453
  * SQL Server: '1' (the first column), PostgreSQL: null
544
454
  */
545
- abstract get SelectListPagingOrderBy(): string | null;
455
+ get SelectListPagingOrderBy(): string | null;
546
456
  /**
547
457
  * Whether skipping rows for a page needs an ORDER BY (`OFFSET … FETCH` does on SQL Server).
548
458
  * When true, a page taken from a derived table is ordered by {@link DefaultPagingOrderBy}.
549
459
  * SQL Server: true, PostgreSQL: false
550
460
  */
551
- abstract get PagingRequiresOrderBy(): boolean;
461
+ get PagingRequiresOrderBy(): boolean;
552
462
  /** {@inheritDoc SQLParserDialect.SupportsEscapeStringLiterals} */
553
- abstract get SupportsEscapeStringLiterals(): boolean;
463
+ get SupportsEscapeStringLiterals(): boolean;
554
464
  /** {@inheritDoc SQLParserDialect.SupportsDollarQuotedStrings} */
555
- abstract get SupportsDollarQuotedStrings(): boolean;
465
+ get SupportsDollarQuotedStrings(): boolean;
556
466
  /** {@inheritDoc SQLParserDialect.QueryHintKeyword} */
557
- abstract get QueryHintKeyword(): string | null;
467
+ get QueryHintKeyword(): string | null;
558
468
  /** {@inheritDoc SQLParserDialect.CallerSQLForbiddenFunctions} */
559
- abstract get CallerSQLForbiddenFunctions(): readonly string[];
469
+ get CallerSQLForbiddenFunctions(): readonly string[];
470
+ /** {@inheritDoc SQLParserDialect.UnseparatedStatementKeywords} */
471
+ get UnseparatedStatementKeywords(): readonly string[];
560
472
  /**
561
473
  * Returns the data type mapping for this dialect.
562
474
  */
563
- abstract get TypeMap(): DataTypeMap;
475
+ get TypeMap(): DataTypeMap;
564
476
  /**
565
477
  * Convenience: maps a SQL Server type to this dialect's equivalent.
566
478
  */
@@ -573,24 +485,24 @@ export declare abstract class SQLDialect implements SQLParserDialect {
573
485
  * Returns a parameter placeholder for the given index.
574
486
  * SQL Server: @p0, @p1, ... PostgreSQL: $1, $2, ...
575
487
  */
576
- abstract ParameterPlaceholder(index: number): string;
488
+ ParameterPlaceholder(index: number): string;
577
489
  /**
578
490
  * Returns the string concatenation operator.
579
491
  * SQL Server: "+", PostgreSQL: "||"
580
492
  */
581
- abstract ConcatOperator(): string;
493
+ ConcatOperator(): string;
582
494
  /**
583
495
  * Returns a STRING_SPLIT or equivalent expression.
584
496
  * SQL Server: STRING_SPLIT(value, delimiter)
585
497
  * PostgreSQL: string_to_array(value, delimiter) or regexp_split_to_table
586
498
  */
587
- abstract StringSplitFunction(value: string, delimiter: string): string;
499
+ StringSplitFunction(value: string, delimiter: string): string;
588
500
  /**
589
501
  * Returns a JSON value extraction expression.
590
502
  * SQL Server: JSON_VALUE(column, path)
591
503
  * PostgreSQL: column->>'path' or jsonb_extract_path_text
592
504
  */
593
- abstract JsonExtract(column: string, path: string): string;
505
+ JsonExtract(column: string, path: string): string;
594
506
  /**
595
507
  * Splits `${...}` inside SQL string literals so Flyway doesn't treat
596
508
  * them as placeholders. Each `${name}` becomes a concat-split that
@@ -598,19 +510,19 @@ export declare abstract class SQLDialect implements SQLParserDialect {
598
510
  * `${` in the file text. Form is platform-specific (concat operator,
599
511
  * truncation rules) — see each dialect's implementation.
600
512
  */
601
- abstract EscapeFlywayStringInterpolation(sql: string): string;
513
+ EscapeFlywayStringInterpolation(sql: string): string;
602
514
  /**
603
515
  * Returns the SQL syntax for calling a stored procedure or function.
604
516
  * SQL Server: EXEC [schema].[name] @p0, @p1
605
517
  * PostgreSQL: SELECT * FROM schema.name($1, $2)
606
518
  */
607
- abstract ProcedureCallSyntax(schema: string, name: string, params: string[]): string;
519
+ ProcedureCallSyntax(schema: string, name: string, params: string[]): string;
608
520
  /**
609
521
  * Returns CREATE SCHEMA IF NOT EXISTS SQL.
610
522
  * SQL Server: IF NOT EXISTS (...) EXEC('CREATE SCHEMA [name]'); GO
611
523
  * PostgreSQL: CREATE SCHEMA IF NOT EXISTS "name";
612
524
  */
613
- abstract CreateSchemaDDL(schemaName: string): string;
525
+ CreateSchemaDDL(schemaName: string): string;
614
526
  /**
615
527
  * Cap a column type if it cannot be used in a UNIQUE/index constraint.
616
528
  * SQL Server: NVARCHAR(MAX) → NVARCHAR(450) (MAX columns cannot be indexed).
@@ -623,13 +535,13 @@ export declare abstract class SQLDialect implements SQLParserDialect {
623
535
  * SQL Server: ADD [colName] type NULL DEFAULT ...
624
536
  * PostgreSQL: ADD COLUMN "colName" type NULL DEFAULT ...
625
537
  */
626
- abstract AddColumnClause(col: ColumnDDLOptions): string;
538
+ AddColumnClause(col: ColumnDDLOptions): string;
627
539
  /**
628
540
  * Returns ALTER COLUMN clause(s) for type/nullability changes.
629
541
  * SQL Server: ALTER TABLE t ALTER COLUMN [col] newType NULL/NOT NULL;
630
542
  * PostgreSQL: ALTER TABLE t ALTER COLUMN "col" TYPE newType, ALTER COLUMN "col" SET/DROP NOT NULL;
631
543
  */
632
- abstract AlterColumnDDL(quotedTable: string, options: AlterColumnOptions): string;
544
+ AlterColumnDDL(quotedTable: string, options: AlterColumnOptions): string;
633
545
  /**
634
546
  * Returns description metadata SQL for a column.
635
547
  * SQL Server: EXEC sp_addextendedproperty with @level2type = 'COLUMN'
@@ -638,20 +550,20 @@ export declare abstract class SQLDialect implements SQLParserDialect {
638
550
  * This extends CommentOnObject to support the 3-part column reference
639
551
  * that CommentOnObject doesn't handle.
640
552
  */
641
- abstract CommentOnColumn(schema: string, table: string, column: string, comment: string): string;
553
+ CommentOnColumn(schema: string, table: string, column: string, comment: string): string;
642
554
  /**
643
555
  * Returns the platform's fallback type for unknown/unmapped abstract types.
644
556
  * SQL Server: NVARCHAR(MAX)
645
557
  * PostgreSQL: TEXT
646
558
  */
647
- abstract FallbackType(): string;
559
+ FallbackType(): string;
648
560
  /**
649
561
  * Resolves an abstract schema field type to a concrete SQL type string.
650
562
  * Used by SchemaEngine for DDL generation from platform-agnostic definitions.
651
563
  * SQL Server: 'string' -> 'NVARCHAR(255)', 'boolean' -> 'BIT'
652
564
  * PostgreSQL: 'string' -> 'VARCHAR(255)', 'boolean' -> 'BOOLEAN'
653
565
  */
654
- abstract ResolveAbstractType(options: ResolveTypeOptions): string;
566
+ ResolveAbstractType(options: ResolveTypeOptions): string;
655
567
  /**
656
568
  * Returns a date/time arithmetic expression.
657
569
  * SQL Server: DATEADD(MINUTE, 30, GETUTCDATE())
@@ -661,7 +573,7 @@ export declare abstract class SQLDialect implements SQLParserDialect {
661
573
  * @param amount - Number of units to add (can be negative)
662
574
  * @param baseExpr - Base timestamp expression (e.g., from CurrentTimestampUTC())
663
575
  */
664
- abstract DateAddExpression(unit: 'MINUTE' | 'HOUR' | 'DAY', amount: number, baseExpr: string): string;
576
+ DateAddExpression(unit: DateAddUnit, amount: number, baseExpr: string): string;
665
577
  /**
666
578
  * Returns a full CREATE TABLE wrapped in a "create if not exists" guard.
667
579
  * SQL Server: IF NOT EXISTS (sys.tables check) BEGIN CREATE TABLE ... END;
@@ -671,7 +583,7 @@ export declare abstract class SQLDialect implements SQLParserDialect {
671
583
  * @param tableName - Table name
672
584
  * @param columnsDDL - The column definitions (everything between the parentheses)
673
585
  */
674
- abstract CreateTableIfNotExistsDDL(schema: string, tableName: string, columnsDDL: string): string;
586
+ CreateTableIfNotExistsDDL(schema: string, tableName: string, columnsDDL: string): string;
675
587
  /**
676
588
  * Returns a conditional IF/ELSE block in platform-appropriate procedural SQL.
677
589
  * SQL Server: IF (condition) BEGIN thenSQL END ELSE BEGIN elseSQL END
@@ -681,7 +593,7 @@ export declare abstract class SQLDialect implements SQLParserDialect {
681
593
  * @param thenSQL - SQL to execute when condition is true
682
594
  * @param elseSQL - Optional SQL to execute when condition is false
683
595
  */
684
- abstract ConditionalBlock(condition: string, thenSQL: string, elseSQL?: string): string;
596
+ ConditionalBlock(condition: string, thenSQL: string, elseSQL?: string): string;
685
597
  /**
686
598
  * Returns a non-fatal signal/notice statement detectable in CLI output.
687
599
  * Used for signaling conditions (e.g., "lock held") without aborting the script.
@@ -692,23 +604,23 @@ export declare abstract class SQLDialect implements SQLParserDialect {
692
604
  *
693
605
  * @param message - Signal message to emit (used for detection in CLI output)
694
606
  */
695
- abstract RaiseSignalSQL(message: string): string;
607
+ RaiseSignalSQL(message: string): string;
696
608
  /**
697
609
  * Generates trigger DDL for the platform.
698
610
  */
699
- abstract TriggerDDL(options: TriggerOptions): string;
611
+ TriggerDDL(options: TriggerOptions): string;
700
612
  /**
701
613
  * Generates index DDL for the platform.
702
614
  */
703
- abstract IndexDDL(options: IndexOptions): string;
615
+ IndexDDL(options: IndexOptions): string;
704
616
  /**
705
617
  * Returns a GRANT statement for the platform.
706
618
  */
707
- abstract GrantPermission(permission: string, objectType: string, schema: string, object: string, role: string): string;
619
+ GrantPermission(permission: string, objectType: string, schema: string, object: string, role: string): string;
708
620
  /**
709
621
  * Returns a COMMENT ON statement (PostgreSQL) or sp_addextendedproperty (SQL Server).
710
622
  */
711
- abstract CommentOnObject(objectType: string, schema: string, name: string, comment: string): string;
623
+ CommentOnObject(objectType: string, schema: string, name: string, comment: string): string;
712
624
  /**
713
625
  * A full CREATE TABLE that runs only if the table is absent, as a SINGLE statement.
714
626
  * Default (PostgreSQL et al.): `CREATE TABLE IF NOT EXISTS <fullTable> (...);`
@@ -734,7 +646,7 @@ export declare abstract class SQLDialect implements SQLParserDialect {
734
646
  /**
735
647
  * Returns platform-specific schema introspection queries.
736
648
  */
737
- abstract SchemaIntrospectionQueries(): SchemaIntrospectionSQL;
649
+ SchemaIntrospectionQueries(): SchemaIntrospectionSQL;
738
650
  /**
739
651
  * Returns a ready-to-run (no bind parameters) query that enumerates the foreign-key graph
740
652
  * of a single schema, for FK-cascade planning (e.g. Open-App metadata teardown).
@@ -755,7 +667,7 @@ export declare abstract class SQLDialect implements SQLParserDialect {
755
667
  *
756
668
  * @param schema the schema whose intra-schema FK edges to enumerate (e.g. `__mj`)
757
669
  */
758
- abstract ForeignKeyGraphSQL(schema: string): string;
670
+ ForeignKeyGraphSQL(schema: string): string;
759
671
  /**
760
672
  * Wraps a list of statements in ONE all-or-nothing transaction batch for this platform, ready to
761
673
  * run as a single `ExecuteSQL(script)` call. Owns the platform-specific session/transaction setup
@@ -771,16 +683,13 @@ export declare abstract class SQLDialect implements SQLParserDialect {
771
683
  *
772
684
  * @param statements individual SQL statements (each WITHOUT a trailing `;`)
773
685
  */
774
- abstract AtomicBatchScript(statements: string[]): string;
686
+ AtomicBatchScript(statements: string[]): string;
775
687
  /**
776
688
  * Returns the platform's two-argument null-coalescing expression.
777
689
  * SQL Server: `ISNULL(expr, fallback)`, PostgreSQL: `COALESCE(expr, fallback)`.
778
- * Abstract because each dialect must declare its own keyword — there is no
779
- * safe default. A future dialect that has neither `ISNULL` nor `COALESCE`
780
- * would silently emit invalid SQL if this fell through to a base
781
- * implementation.
690
+ * The dialect's writer declares the keyword.
782
691
  */
783
- abstract IsNull(expr: string, fallback: string): string;
692
+ IsNull(expr: string, fallback: string): string;
784
693
  /**
785
694
  * Returns true if the given error represents an infrastructure-level
786
695
  * connection failure (timeout, refused, pool closed, etc.) as opposed to
@@ -793,28 +702,28 @@ export declare abstract class SQLDialect implements SQLParserDialect {
793
702
  * Used by GenericDatabaseProvider to re-throw connection errors from
794
703
  * RunView/RunQuery instead of swallowing them into `{ Success: false }`.
795
704
  */
796
- abstract IsConnectionError(e: unknown): boolean;
705
+ IsConnectionError(e: unknown): boolean;
797
706
  /**
798
707
  * Returns an IIF/CASE equivalent expression.
799
708
  * SQL Server: IIF(condition, trueVal, falseVal)
800
709
  * PostgreSQL: CASE WHEN condition THEN trueVal ELSE falseVal END
801
710
  */
802
- abstract IIF(condition: string, trueVal: string, falseVal: string): string;
711
+ IIF(condition: string, trueVal: string, falseVal: string): string;
803
712
  /**
804
713
  * SQL that marks a nested transaction savepoint. SQL Server:
805
714
  * `SAVE TRANSACTION name`. PostgreSQL: `SAVEPOINT name`.
806
715
  */
807
- abstract CreateSavepointSQL(name: string): string;
716
+ CreateSavepointSQL(name: string): string;
808
717
  /**
809
718
  * SQL that discards a savepoint after a nested commit, or `null` when the
810
719
  * platform has no release (SQL Server savepoints live until the outer TX
811
720
  * ends). PostgreSQL: `RELEASE SAVEPOINT name`.
812
721
  */
813
- abstract ReleaseSavepointSQL(name: string): string | null;
722
+ ReleaseSavepointSQL(name: string): string | null;
814
723
  /**
815
724
  * SQL that undoes work after a savepoint. SQL Server:
816
725
  * `ROLLBACK TRANSACTION name`. PostgreSQL: `ROLLBACK TO SAVEPOINT name`.
817
726
  */
818
- abstract RollbackToSavepointSQL(name: string): string;
727
+ RollbackToSavepointSQL(name: string): string;
819
728
  }
820
729
  //# sourceMappingURL=sqlDialect.d.ts.map