@memberjunction/sql-dialect 6.2.0-edge.5 → 6.2.0-edge.7
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/README.md +280 -91
- package/dist/dialectFactory.d.ts +37 -5
- package/dist/dialectFactory.d.ts.map +1 -1
- package/dist/dialectFactory.js +106 -14
- package/dist/dialectFactory.js.map +1 -1
- package/dist/dialects/ansi.d.ts +55 -0
- package/dist/dialects/ansi.d.ts.map +1 -0
- package/dist/dialects/ansi.js +136 -0
- package/dist/dialects/ansi.js.map +1 -0
- package/dist/dialects/baseSchemaDDL.d.ts +78 -0
- package/dist/dialects/baseSchemaDDL.d.ts.map +1 -0
- package/dist/dialects/baseSchemaDDL.js +63 -0
- package/dist/dialects/baseSchemaDDL.js.map +1 -0
- package/dist/dialects/databricksQueryDialect.d.ts +41 -0
- package/dist/dialects/databricksQueryDialect.d.ts.map +1 -0
- package/dist/dialects/databricksQueryDialect.js +103 -0
- package/dist/dialects/databricksQueryDialect.js.map +1 -0
- package/dist/dialects/mysqlQueryDialect.d.ts +46 -0
- package/dist/dialects/mysqlQueryDialect.d.ts.map +1 -0
- package/dist/dialects/mysqlQueryDialect.js +117 -0
- package/dist/dialects/mysqlQueryDialect.js.map +1 -0
- package/dist/dialects/oracleQueryDialect.d.ts +42 -0
- package/dist/dialects/oracleQueryDialect.d.ts.map +1 -0
- package/dist/dialects/oracleQueryDialect.js +92 -0
- package/dist/dialects/oracleQueryDialect.js.map +1 -0
- package/dist/dialects/postgresqlSchemaDDL.d.ts +112 -0
- package/dist/dialects/postgresqlSchemaDDL.d.ts.map +1 -0
- package/dist/dialects/postgresqlSchemaDDL.js +590 -0
- package/dist/dialects/postgresqlSchemaDDL.js.map +1 -0
- package/dist/dialects/snowflakeQueryDialect.d.ts +41 -0
- package/dist/dialects/snowflakeQueryDialect.d.ts.map +1 -0
- package/dist/dialects/snowflakeQueryDialect.js +94 -0
- package/dist/dialects/snowflakeQueryDialect.js.map +1 -0
- package/dist/dialects/sqlServerSchemaDDL.d.ts +83 -0
- package/dist/dialects/sqlServerSchemaDDL.d.ts.map +1 -0
- package/dist/dialects/sqlServerSchemaDDL.js +507 -0
- package/dist/dialects/sqlServerSchemaDDL.js.map +1 -0
- package/dist/facets/dialectBinding.d.ts +26 -0
- package/dist/facets/dialectBinding.d.ts.map +1 -0
- package/dist/facets/dialectBinding.js +2 -0
- package/dist/facets/dialectBinding.js.map +1 -0
- package/dist/facets/dialectGrammar.d.ts +82 -0
- package/dist/facets/dialectGrammar.d.ts.map +1 -0
- package/dist/facets/dialectGrammar.js +2 -0
- package/dist/facets/dialectGrammar.js.map +1 -0
- package/dist/facets/dialectKey.d.ts +9 -0
- package/dist/facets/dialectKey.d.ts.map +1 -0
- package/dist/facets/dialectKey.js +2 -0
- package/dist/facets/dialectKey.js.map +1 -0
- package/dist/facets/dialectLexicalRules.d.ts +102 -0
- package/dist/facets/dialectLexicalRules.d.ts.map +1 -0
- package/dist/facets/dialectLexicalRules.js +2 -0
- package/dist/facets/dialectLexicalRules.js.map +1 -0
- package/dist/facets/dialectSchemaDDL.d.ts +213 -0
- package/dist/facets/dialectSchemaDDL.d.ts.map +1 -0
- package/dist/facets/dialectSchemaDDL.js +2 -0
- package/dist/facets/dialectSchemaDDL.js.map +1 -0
- package/dist/facets/dialectTypes.d.ts +31 -0
- package/dist/facets/dialectTypes.d.ts.map +1 -0
- package/dist/facets/dialectTypes.js +2 -0
- package/dist/facets/dialectTypes.js.map +1 -0
- package/dist/facets/dialectWriter.d.ts +59 -0
- package/dist/facets/dialectWriter.d.ts.map +1 -0
- package/dist/facets/dialectWriter.js +2 -0
- package/dist/facets/dialectWriter.js.map +1 -0
- package/dist/identifierReferences.d.ts +8 -1
- package/dist/identifierReferences.d.ts.map +1 -1
- package/dist/identifierReferences.js +8 -1
- package/dist/identifierReferences.js.map +1 -1
- package/dist/index.d.ts +22 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +14 -5
- package/dist/index.js.map +1 -1
- package/dist/postgresqlAutoQuote.d.ts +10 -0
- package/dist/postgresqlAutoQuote.d.ts.map +1 -1
- package/dist/postgresqlAutoQuote.js +12 -0
- package/dist/postgresqlAutoQuote.js.map +1 -1
- package/dist/postgresqlDialect.d.ts +57 -149
- package/dist/postgresqlDialect.d.ts.map +1 -1
- package/dist/postgresqlDialect.js +110 -676
- package/dist/postgresqlDialect.js.map +1 -1
- package/dist/postgresqlRestarLayeredOuter.d.ts.map +1 -1
- package/dist/postgresqlRestarLayeredOuter.js +45 -15
- package/dist/postgresqlRestarLayeredOuter.js.map +1 -1
- package/dist/queryDialect.d.ts +42 -0
- package/dist/queryDialect.d.ts.map +1 -0
- package/dist/queryDialect.js +25 -0
- package/dist/queryDialect.js.map +1 -0
- package/dist/sqlDialect.d.ts +148 -212
- package/dist/sqlDialect.d.ts.map +1 -1
- package/dist/sqlDialect.js +751 -29
- package/dist/sqlDialect.js.map +1 -1
- package/dist/sqlServerDialect.d.ts +54 -117
- package/dist/sqlServerDialect.d.ts.map +1 -1
- package/dist/sqlServerDialect.js +124 -587
- package/dist/sqlServerDialect.js.map +1 -1
- package/package.json +4 -2
package/dist/sqlDialect.d.ts
CHANGED
|
@@ -1,4 +1,13 @@
|
|
|
1
|
-
import {
|
|
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
|
-
*
|
|
133
|
-
*
|
|
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
|
|
67
|
+
* Abstract base class for the dialects of the platforms MJ itself runs on.
|
|
165
68
|
*
|
|
166
|
-
*
|
|
167
|
-
*
|
|
168
|
-
*
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
212
|
-
*
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
@@ -287,10 +198,37 @@ export declare abstract class SQLDialect implements SQLParserDialect {
|
|
|
287
198
|
* dialect-aware SQL surface in one place per the SQLDialect contract.
|
|
288
199
|
*/
|
|
289
200
|
LowerCase(expr: string): string;
|
|
201
|
+
/**
|
|
202
|
+
* Human-readable name for this dialect, as it should appear to a person
|
|
203
|
+
* — or to an LLM being told which SQL to write.
|
|
204
|
+
*
|
|
205
|
+
* Abstract on purpose: the name is dialect knowledge, so a new dialect
|
|
206
|
+
* declares it once here rather than every prompt/UI keeping its own map.
|
|
207
|
+
*/
|
|
208
|
+
abstract get DisplayName(): string;
|
|
209
|
+
/**
|
|
210
|
+
* The `sql-formatter` language key for this dialect (e.g. `'tsql'`,
|
|
211
|
+
* `'postgresql'`). Callers that pretty-print generated SQL read this
|
|
212
|
+
* instead of hardcoding a language, so formatting follows the tenant's
|
|
213
|
+
* actual platform.
|
|
214
|
+
*/
|
|
215
|
+
abstract get FormatterLanguage(): string;
|
|
216
|
+
/**
|
|
217
|
+
* A syntax briefing for this dialect, composed ENTIRELY from this class's
|
|
218
|
+
* own primitives — nothing here is a hand-maintained per-dialect prose
|
|
219
|
+
* table. Implementing the dialect is therefore sufficient to get correct
|
|
220
|
+
* guidance; there is no second list to remember to update.
|
|
221
|
+
*
|
|
222
|
+
* Consumed by the `_SQL_DIALECT_RULES` system placeholder, which makes it
|
|
223
|
+
* available to EVERY AI prompt template without any template having to be
|
|
224
|
+
* registered anywhere. That is the point: the set of SQL-generating
|
|
225
|
+
* templates is a predicate ("does it ask for SQL?"), never a list of IDs.
|
|
226
|
+
*/
|
|
227
|
+
get PromptGuidance(): string;
|
|
290
228
|
/** SQL type names this dialect uses for boolean columns. */
|
|
291
|
-
|
|
229
|
+
get BooleanTypeNames(): readonly string[];
|
|
292
230
|
/** SQL type names this dialect uses for variable-length character / text columns. */
|
|
293
|
-
|
|
231
|
+
get StringTypeNames(): readonly string[];
|
|
294
232
|
/**
|
|
295
233
|
* Subset of {@link StringTypeNames} that represents **fixed-width** /
|
|
296
234
|
* space-padded character types. SQL Server `char`/`nchar` and PostgreSQL
|
|
@@ -302,7 +240,7 @@ export declare abstract class SQLDialect implements SQLParserDialect {
|
|
|
302
240
|
* Used by `BaseEntity` to rtrim padding on load so dirty-checks and
|
|
303
241
|
* downstream consumers see the logical value, not the storage form.
|
|
304
242
|
*/
|
|
305
|
-
|
|
243
|
+
get FixedWidthStringTypeNames(): readonly string[];
|
|
306
244
|
/**
|
|
307
245
|
* Maximum string length usable in an INDEX KEY column (PRIMARY KEY / UNIQUE constraint) on this
|
|
308
246
|
* dialect. A PK string column wider than this can't be indexed, so callers (e.g. the integration
|
|
@@ -331,37 +269,36 @@ export declare abstract class SQLDialect implements SQLParserDialect {
|
|
|
331
269
|
* their full size. Only meaningful for dialects that report a {@link MaxInRowSizeBytes}.
|
|
332
270
|
* Default: 24 (a conservative off-row-pointer floor).
|
|
333
271
|
*/
|
|
334
|
-
EstimateInRowBytes(
|
|
272
|
+
EstimateInRowBytes(rawSqlType: string): number;
|
|
335
273
|
/** SQL type names this dialect uses for date / time / timestamp columns. */
|
|
336
|
-
|
|
274
|
+
get DateTypeNames(): readonly string[];
|
|
337
275
|
/** SQL type names this dialect uses for integer columns (int, bigint, smallint, …). */
|
|
338
|
-
|
|
276
|
+
get IntegerTypeNames(): readonly string[];
|
|
339
277
|
/** SQL type names this dialect uses for floating-point / decimal columns. */
|
|
340
|
-
|
|
278
|
+
get FloatTypeNames(): readonly string[];
|
|
341
279
|
/** SQL type names this dialect uses for UUID / uniqueidentifier columns. */
|
|
342
|
-
|
|
280
|
+
get UuidTypeNames(): readonly string[];
|
|
343
281
|
/** SQL type names this dialect uses for binary blob columns (image, bytea, varbinary). */
|
|
344
|
-
|
|
282
|
+
get BinaryTypeNames(): readonly string[];
|
|
345
283
|
/** SQL type names this dialect uses for JSON / XML structured columns. */
|
|
346
|
-
|
|
284
|
+
get JsonTypeNames(): readonly string[];
|
|
347
285
|
/** SQL type names this dialect uses for fixed-precision currency columns. */
|
|
348
|
-
|
|
286
|
+
get CurrencyTypeNames(): readonly string[];
|
|
349
287
|
/** SQL type names this dialect uses for interval / duration columns. */
|
|
350
|
-
|
|
288
|
+
get IntervalTypeNames(): readonly string[];
|
|
351
289
|
/** SQL type names this dialect uses for network address columns (inet, cidr, …). */
|
|
352
|
-
|
|
290
|
+
get NetworkTypeNames(): readonly string[];
|
|
353
291
|
/**
|
|
354
292
|
* Returns a new UUID generation expression.
|
|
355
293
|
* SQL Server: NEWID(), PostgreSQL: gen_random_uuid()
|
|
356
294
|
*/
|
|
357
|
-
|
|
295
|
+
NewUUID(): string;
|
|
358
296
|
/**
|
|
359
297
|
* Returns the platform's n-ary null-coalescing expression. SQL Server and
|
|
360
|
-
* PostgreSQL both spell this `COALESCE(...)
|
|
361
|
-
*
|
|
362
|
-
* declare its own form rather than inheriting an opinionated default.
|
|
298
|
+
* PostgreSQL both spell this `COALESCE(...)`; the dialect's writer owns
|
|
299
|
+
* the spelling.
|
|
363
300
|
*/
|
|
364
|
-
|
|
301
|
+
Coalesce(expr: string, fallback: string): string;
|
|
365
302
|
/**
|
|
366
303
|
* Returns the dialect's literal representation of NULL as it would
|
|
367
304
|
* appear in generated SQL (e.g. as the result of a default-value
|
|
@@ -383,19 +320,19 @@ export declare abstract class SQLDialect implements SQLParserDialect {
|
|
|
383
320
|
* SQL Server: `@MyName`, PostgreSQL functions: `p_my_name`.
|
|
384
321
|
* Codegen should call this rather than hard-coding `'@' + name`.
|
|
385
322
|
*/
|
|
386
|
-
|
|
323
|
+
ParameterRef(name: string): string;
|
|
387
324
|
/**
|
|
388
325
|
* Returns the default-value clause appended to a parameter declaration.
|
|
389
326
|
* SQL Server: ` = NULL` (or ` = 0`, etc.), PostgreSQL: ` DEFAULT NULL`.
|
|
390
327
|
* `value` should be a SQL literal already formatted by the caller (e.g.
|
|
391
328
|
* the dialect's NullLiteral, a quoted string, a numeric literal).
|
|
392
329
|
*/
|
|
393
|
-
|
|
330
|
+
ParameterDefault(value: string): string;
|
|
394
331
|
/**
|
|
395
332
|
* Returns a CAST-to-text expression.
|
|
396
333
|
* SQL Server: CAST(expr AS NVARCHAR(MAX)), PostgreSQL: CAST(expr AS TEXT)
|
|
397
334
|
*/
|
|
398
|
-
|
|
335
|
+
CastToText(expr: string): string;
|
|
399
336
|
/**
|
|
400
337
|
* Returns a CAST to a bounded-width string type. Used when the result
|
|
401
338
|
* needs to be comparable against an indexed column (SQL Server cannot
|
|
@@ -412,7 +349,7 @@ export declare abstract class SQLDialect implements SQLParserDialect {
|
|
|
412
349
|
* Returns a CAST-to-UUID expression.
|
|
413
350
|
* SQL Server: CAST(expr AS UNIQUEIDENTIFIER), PostgreSQL: CAST(expr AS UUID)
|
|
414
351
|
*/
|
|
415
|
-
|
|
352
|
+
CastToUUID(expr: string): string;
|
|
416
353
|
/**
|
|
417
354
|
* Returns the empty-GUID sentinel literal
|
|
418
355
|
* (`00000000-0000-0000-0000-000000000000`) formatted for use in a
|
|
@@ -427,32 +364,32 @@ export declare abstract class SQLDialect implements SQLParserDialect {
|
|
|
427
364
|
* SQL Server: OUTPUT INSERTED.col1, INSERTED.col2
|
|
428
365
|
* PostgreSQL: RETURNING col1, col2
|
|
429
366
|
*/
|
|
430
|
-
|
|
367
|
+
ReturnInsertedClause(columns?: string[]): string;
|
|
431
368
|
/**
|
|
432
369
|
* Returns the auto-increment PK expression for DDL.
|
|
433
370
|
* SQL Server: IDENTITY(1,1), PostgreSQL: GENERATED ALWAYS AS IDENTITY
|
|
434
371
|
*/
|
|
435
|
-
|
|
372
|
+
AutoIncrementPKExpression(): string;
|
|
436
373
|
/**
|
|
437
374
|
* Returns the default expression for a UUID primary key.
|
|
438
375
|
* SQL Server: NEWSEQUENTIALID(), PostgreSQL: gen_random_uuid()
|
|
439
376
|
*/
|
|
440
|
-
|
|
377
|
+
UUIDPKDefault(): string;
|
|
441
378
|
/**
|
|
442
379
|
* Returns the expression to get the last inserted identity value.
|
|
443
380
|
* SQL Server: SCOPE_IDENTITY(), PostgreSQL: lastval()
|
|
444
381
|
*/
|
|
445
|
-
|
|
382
|
+
ScopeIdentityExpression(): string;
|
|
446
383
|
/**
|
|
447
384
|
* Returns the row count variable/expression for the last statement.
|
|
448
385
|
* SQL Server: @@ROWCOUNT, PostgreSQL: (via GET DIAGNOSTICS or FOUND)
|
|
449
386
|
*/
|
|
450
|
-
|
|
387
|
+
RowCountExpression(): string;
|
|
451
388
|
/**
|
|
452
389
|
* Returns the batch separator for the platform.
|
|
453
390
|
* SQL Server: "GO", PostgreSQL: "" (none needed)
|
|
454
391
|
*/
|
|
455
|
-
|
|
392
|
+
BatchSeparator(): string;
|
|
456
393
|
/**
|
|
457
394
|
* Splits an oversized SQL batch into individual statements on `;`+EOL
|
|
458
395
|
* boundaries so a caller (e.g. the RSU migration executor) can re-group
|
|
@@ -474,66 +411,68 @@ export declare abstract class SQLDialect implements SQLParserDialect {
|
|
|
474
411
|
* @param schema - Schema name
|
|
475
412
|
* @param name - Object name
|
|
476
413
|
*/
|
|
477
|
-
|
|
414
|
+
ExistenceCheckSQL(objectType: string, schema: string, name: string): string;
|
|
478
415
|
/**
|
|
479
416
|
* Whether the platform supports CREATE OR REPLACE for a given object type.
|
|
480
417
|
* PostgreSQL supports it for FUNCTION, VIEW. SQL Server does not.
|
|
481
418
|
*/
|
|
482
|
-
|
|
419
|
+
CreateOrReplaceSupported(objectType: string): boolean;
|
|
483
420
|
/**
|
|
484
421
|
* Returns a full-text search predicate expression.
|
|
485
422
|
* SQL Server: CONTAINS(column, searchTerm)
|
|
486
423
|
* PostgreSQL: column @@ plainto_tsquery('english', searchTerm)
|
|
487
424
|
*/
|
|
488
|
-
|
|
425
|
+
FullTextSearchPredicate(column: string, searchTerm: string): string;
|
|
489
426
|
/**
|
|
490
427
|
* Returns DDL to create a full-text index.
|
|
491
428
|
* SQL Server: FULLTEXT CATALOG + FULLTEXT INDEX
|
|
492
429
|
* PostgreSQL: tsvector column + GIN index
|
|
493
430
|
*/
|
|
494
|
-
|
|
431
|
+
FullTextIndexDDL(table: string, columns: string[], catalog?: string): string;
|
|
495
432
|
/**
|
|
496
433
|
* Returns the recursive CTE syntax keyword.
|
|
497
434
|
* SQL Server: "WITH", PostgreSQL: "WITH RECURSIVE"
|
|
498
435
|
*/
|
|
499
|
-
|
|
436
|
+
RecursiveCTESyntax(): string;
|
|
500
437
|
/**
|
|
501
438
|
* Whether the platform allows ORDER BY inside CTE definitions without
|
|
502
439
|
* TOP, OFFSET, or FOR XML.
|
|
503
440
|
* SQL Server: false (ORDER BY in CTEs is illegal without TOP/OFFSET/FOR XML)
|
|
504
441
|
* PostgreSQL: true (ORDER BY in CTEs is always legal)
|
|
505
442
|
*/
|
|
506
|
-
|
|
443
|
+
get AllowsOrderByInCTE(): boolean;
|
|
507
444
|
/**
|
|
508
445
|
* Default ORDER BY expression for paging when no user-specified ORDER BY exists.
|
|
509
446
|
* SQL Server: '(SELECT NULL)', PostgreSQL: '1'
|
|
510
447
|
*/
|
|
511
|
-
|
|
448
|
+
get DefaultPagingOrderBy(): string;
|
|
512
449
|
/**
|
|
513
450
|
* The ORDER BY expression for paging a set operation (`UNION` / `INTERSECT` / `EXCEPT`) or a
|
|
514
451
|
* `SELECT DISTINCT` that has no ORDER BY of its own, on a platform that only accepts select-list
|
|
515
452
|
* items there. `null` when {@link DefaultPagingOrderBy} is accepted for those shapes too.
|
|
516
453
|
* SQL Server: '1' (the first column), PostgreSQL: null
|
|
517
454
|
*/
|
|
518
|
-
|
|
455
|
+
get SelectListPagingOrderBy(): string | null;
|
|
519
456
|
/**
|
|
520
457
|
* Whether skipping rows for a page needs an ORDER BY (`OFFSET … FETCH` does on SQL Server).
|
|
521
458
|
* When true, a page taken from a derived table is ordered by {@link DefaultPagingOrderBy}.
|
|
522
459
|
* SQL Server: true, PostgreSQL: false
|
|
523
460
|
*/
|
|
524
|
-
|
|
461
|
+
get PagingRequiresOrderBy(): boolean;
|
|
525
462
|
/** {@inheritDoc SQLParserDialect.SupportsEscapeStringLiterals} */
|
|
526
|
-
|
|
463
|
+
get SupportsEscapeStringLiterals(): boolean;
|
|
527
464
|
/** {@inheritDoc SQLParserDialect.SupportsDollarQuotedStrings} */
|
|
528
|
-
|
|
465
|
+
get SupportsDollarQuotedStrings(): boolean;
|
|
529
466
|
/** {@inheritDoc SQLParserDialect.QueryHintKeyword} */
|
|
530
|
-
|
|
467
|
+
get QueryHintKeyword(): string | null;
|
|
531
468
|
/** {@inheritDoc SQLParserDialect.CallerSQLForbiddenFunctions} */
|
|
532
|
-
|
|
469
|
+
get CallerSQLForbiddenFunctions(): readonly string[];
|
|
470
|
+
/** {@inheritDoc SQLParserDialect.UnseparatedStatementKeywords} */
|
|
471
|
+
get UnseparatedStatementKeywords(): readonly string[];
|
|
533
472
|
/**
|
|
534
473
|
* Returns the data type mapping for this dialect.
|
|
535
474
|
*/
|
|
536
|
-
|
|
475
|
+
get TypeMap(): DataTypeMap;
|
|
537
476
|
/**
|
|
538
477
|
* Convenience: maps a SQL Server type to this dialect's equivalent.
|
|
539
478
|
*/
|
|
@@ -546,24 +485,24 @@ export declare abstract class SQLDialect implements SQLParserDialect {
|
|
|
546
485
|
* Returns a parameter placeholder for the given index.
|
|
547
486
|
* SQL Server: @p0, @p1, ... PostgreSQL: $1, $2, ...
|
|
548
487
|
*/
|
|
549
|
-
|
|
488
|
+
ParameterPlaceholder(index: number): string;
|
|
550
489
|
/**
|
|
551
490
|
* Returns the string concatenation operator.
|
|
552
491
|
* SQL Server: "+", PostgreSQL: "||"
|
|
553
492
|
*/
|
|
554
|
-
|
|
493
|
+
ConcatOperator(): string;
|
|
555
494
|
/**
|
|
556
495
|
* Returns a STRING_SPLIT or equivalent expression.
|
|
557
496
|
* SQL Server: STRING_SPLIT(value, delimiter)
|
|
558
497
|
* PostgreSQL: string_to_array(value, delimiter) or regexp_split_to_table
|
|
559
498
|
*/
|
|
560
|
-
|
|
499
|
+
StringSplitFunction(value: string, delimiter: string): string;
|
|
561
500
|
/**
|
|
562
501
|
* Returns a JSON value extraction expression.
|
|
563
502
|
* SQL Server: JSON_VALUE(column, path)
|
|
564
503
|
* PostgreSQL: column->>'path' or jsonb_extract_path_text
|
|
565
504
|
*/
|
|
566
|
-
|
|
505
|
+
JsonExtract(column: string, path: string): string;
|
|
567
506
|
/**
|
|
568
507
|
* Splits `${...}` inside SQL string literals so Flyway doesn't treat
|
|
569
508
|
* them as placeholders. Each `${name}` becomes a concat-split that
|
|
@@ -571,19 +510,19 @@ export declare abstract class SQLDialect implements SQLParserDialect {
|
|
|
571
510
|
* `${` in the file text. Form is platform-specific (concat operator,
|
|
572
511
|
* truncation rules) — see each dialect's implementation.
|
|
573
512
|
*/
|
|
574
|
-
|
|
513
|
+
EscapeFlywayStringInterpolation(sql: string): string;
|
|
575
514
|
/**
|
|
576
515
|
* Returns the SQL syntax for calling a stored procedure or function.
|
|
577
516
|
* SQL Server: EXEC [schema].[name] @p0, @p1
|
|
578
517
|
* PostgreSQL: SELECT * FROM schema.name($1, $2)
|
|
579
518
|
*/
|
|
580
|
-
|
|
519
|
+
ProcedureCallSyntax(schema: string, name: string, params: string[]): string;
|
|
581
520
|
/**
|
|
582
521
|
* Returns CREATE SCHEMA IF NOT EXISTS SQL.
|
|
583
522
|
* SQL Server: IF NOT EXISTS (...) EXEC('CREATE SCHEMA [name]'); GO
|
|
584
523
|
* PostgreSQL: CREATE SCHEMA IF NOT EXISTS "name";
|
|
585
524
|
*/
|
|
586
|
-
|
|
525
|
+
CreateSchemaDDL(schemaName: string): string;
|
|
587
526
|
/**
|
|
588
527
|
* Cap a column type if it cannot be used in a UNIQUE/index constraint.
|
|
589
528
|
* SQL Server: NVARCHAR(MAX) → NVARCHAR(450) (MAX columns cannot be indexed).
|
|
@@ -596,13 +535,13 @@ export declare abstract class SQLDialect implements SQLParserDialect {
|
|
|
596
535
|
* SQL Server: ADD [colName] type NULL DEFAULT ...
|
|
597
536
|
* PostgreSQL: ADD COLUMN "colName" type NULL DEFAULT ...
|
|
598
537
|
*/
|
|
599
|
-
|
|
538
|
+
AddColumnClause(col: ColumnDDLOptions): string;
|
|
600
539
|
/**
|
|
601
540
|
* Returns ALTER COLUMN clause(s) for type/nullability changes.
|
|
602
541
|
* SQL Server: ALTER TABLE t ALTER COLUMN [col] newType NULL/NOT NULL;
|
|
603
542
|
* PostgreSQL: ALTER TABLE t ALTER COLUMN "col" TYPE newType, ALTER COLUMN "col" SET/DROP NOT NULL;
|
|
604
543
|
*/
|
|
605
|
-
|
|
544
|
+
AlterColumnDDL(quotedTable: string, options: AlterColumnOptions): string;
|
|
606
545
|
/**
|
|
607
546
|
* Returns description metadata SQL for a column.
|
|
608
547
|
* SQL Server: EXEC sp_addextendedproperty with @level2type = 'COLUMN'
|
|
@@ -611,20 +550,20 @@ export declare abstract class SQLDialect implements SQLParserDialect {
|
|
|
611
550
|
* This extends CommentOnObject to support the 3-part column reference
|
|
612
551
|
* that CommentOnObject doesn't handle.
|
|
613
552
|
*/
|
|
614
|
-
|
|
553
|
+
CommentOnColumn(schema: string, table: string, column: string, comment: string): string;
|
|
615
554
|
/**
|
|
616
555
|
* Returns the platform's fallback type for unknown/unmapped abstract types.
|
|
617
556
|
* SQL Server: NVARCHAR(MAX)
|
|
618
557
|
* PostgreSQL: TEXT
|
|
619
558
|
*/
|
|
620
|
-
|
|
559
|
+
FallbackType(): string;
|
|
621
560
|
/**
|
|
622
561
|
* Resolves an abstract schema field type to a concrete SQL type string.
|
|
623
562
|
* Used by SchemaEngine for DDL generation from platform-agnostic definitions.
|
|
624
563
|
* SQL Server: 'string' -> 'NVARCHAR(255)', 'boolean' -> 'BIT'
|
|
625
564
|
* PostgreSQL: 'string' -> 'VARCHAR(255)', 'boolean' -> 'BOOLEAN'
|
|
626
565
|
*/
|
|
627
|
-
|
|
566
|
+
ResolveAbstractType(options: ResolveTypeOptions): string;
|
|
628
567
|
/**
|
|
629
568
|
* Returns a date/time arithmetic expression.
|
|
630
569
|
* SQL Server: DATEADD(MINUTE, 30, GETUTCDATE())
|
|
@@ -634,7 +573,7 @@ export declare abstract class SQLDialect implements SQLParserDialect {
|
|
|
634
573
|
* @param amount - Number of units to add (can be negative)
|
|
635
574
|
* @param baseExpr - Base timestamp expression (e.g., from CurrentTimestampUTC())
|
|
636
575
|
*/
|
|
637
|
-
|
|
576
|
+
DateAddExpression(unit: DateAddUnit, amount: number, baseExpr: string): string;
|
|
638
577
|
/**
|
|
639
578
|
* Returns a full CREATE TABLE wrapped in a "create if not exists" guard.
|
|
640
579
|
* SQL Server: IF NOT EXISTS (sys.tables check) BEGIN CREATE TABLE ... END;
|
|
@@ -644,7 +583,7 @@ export declare abstract class SQLDialect implements SQLParserDialect {
|
|
|
644
583
|
* @param tableName - Table name
|
|
645
584
|
* @param columnsDDL - The column definitions (everything between the parentheses)
|
|
646
585
|
*/
|
|
647
|
-
|
|
586
|
+
CreateTableIfNotExistsDDL(schema: string, tableName: string, columnsDDL: string): string;
|
|
648
587
|
/**
|
|
649
588
|
* Returns a conditional IF/ELSE block in platform-appropriate procedural SQL.
|
|
650
589
|
* SQL Server: IF (condition) BEGIN thenSQL END ELSE BEGIN elseSQL END
|
|
@@ -654,7 +593,7 @@ export declare abstract class SQLDialect implements SQLParserDialect {
|
|
|
654
593
|
* @param thenSQL - SQL to execute when condition is true
|
|
655
594
|
* @param elseSQL - Optional SQL to execute when condition is false
|
|
656
595
|
*/
|
|
657
|
-
|
|
596
|
+
ConditionalBlock(condition: string, thenSQL: string, elseSQL?: string): string;
|
|
658
597
|
/**
|
|
659
598
|
* Returns a non-fatal signal/notice statement detectable in CLI output.
|
|
660
599
|
* Used for signaling conditions (e.g., "lock held") without aborting the script.
|
|
@@ -665,23 +604,23 @@ export declare abstract class SQLDialect implements SQLParserDialect {
|
|
|
665
604
|
*
|
|
666
605
|
* @param message - Signal message to emit (used for detection in CLI output)
|
|
667
606
|
*/
|
|
668
|
-
|
|
607
|
+
RaiseSignalSQL(message: string): string;
|
|
669
608
|
/**
|
|
670
609
|
* Generates trigger DDL for the platform.
|
|
671
610
|
*/
|
|
672
|
-
|
|
611
|
+
TriggerDDL(options: TriggerOptions): string;
|
|
673
612
|
/**
|
|
674
613
|
* Generates index DDL for the platform.
|
|
675
614
|
*/
|
|
676
|
-
|
|
615
|
+
IndexDDL(options: IndexOptions): string;
|
|
677
616
|
/**
|
|
678
617
|
* Returns a GRANT statement for the platform.
|
|
679
618
|
*/
|
|
680
|
-
|
|
619
|
+
GrantPermission(permission: string, objectType: string, schema: string, object: string, role: string): string;
|
|
681
620
|
/**
|
|
682
621
|
* Returns a COMMENT ON statement (PostgreSQL) or sp_addextendedproperty (SQL Server).
|
|
683
622
|
*/
|
|
684
|
-
|
|
623
|
+
CommentOnObject(objectType: string, schema: string, name: string, comment: string): string;
|
|
685
624
|
/**
|
|
686
625
|
* A full CREATE TABLE that runs only if the table is absent, as a SINGLE statement.
|
|
687
626
|
* Default (PostgreSQL et al.): `CREATE TABLE IF NOT EXISTS <fullTable> (...);`
|
|
@@ -707,7 +646,7 @@ export declare abstract class SQLDialect implements SQLParserDialect {
|
|
|
707
646
|
/**
|
|
708
647
|
* Returns platform-specific schema introspection queries.
|
|
709
648
|
*/
|
|
710
|
-
|
|
649
|
+
SchemaIntrospectionQueries(): SchemaIntrospectionSQL;
|
|
711
650
|
/**
|
|
712
651
|
* Returns a ready-to-run (no bind parameters) query that enumerates the foreign-key graph
|
|
713
652
|
* of a single schema, for FK-cascade planning (e.g. Open-App metadata teardown).
|
|
@@ -728,7 +667,7 @@ export declare abstract class SQLDialect implements SQLParserDialect {
|
|
|
728
667
|
*
|
|
729
668
|
* @param schema the schema whose intra-schema FK edges to enumerate (e.g. `__mj`)
|
|
730
669
|
*/
|
|
731
|
-
|
|
670
|
+
ForeignKeyGraphSQL(schema: string): string;
|
|
732
671
|
/**
|
|
733
672
|
* Wraps a list of statements in ONE all-or-nothing transaction batch for this platform, ready to
|
|
734
673
|
* run as a single `ExecuteSQL(script)` call. Owns the platform-specific session/transaction setup
|
|
@@ -744,16 +683,13 @@ export declare abstract class SQLDialect implements SQLParserDialect {
|
|
|
744
683
|
*
|
|
745
684
|
* @param statements individual SQL statements (each WITHOUT a trailing `;`)
|
|
746
685
|
*/
|
|
747
|
-
|
|
686
|
+
AtomicBatchScript(statements: string[]): string;
|
|
748
687
|
/**
|
|
749
688
|
* Returns the platform's two-argument null-coalescing expression.
|
|
750
689
|
* SQL Server: `ISNULL(expr, fallback)`, PostgreSQL: `COALESCE(expr, fallback)`.
|
|
751
|
-
*
|
|
752
|
-
* safe default. A future dialect that has neither `ISNULL` nor `COALESCE`
|
|
753
|
-
* would silently emit invalid SQL if this fell through to a base
|
|
754
|
-
* implementation.
|
|
690
|
+
* The dialect's writer declares the keyword.
|
|
755
691
|
*/
|
|
756
|
-
|
|
692
|
+
IsNull(expr: string, fallback: string): string;
|
|
757
693
|
/**
|
|
758
694
|
* Returns true if the given error represents an infrastructure-level
|
|
759
695
|
* connection failure (timeout, refused, pool closed, etc.) as opposed to
|
|
@@ -766,28 +702,28 @@ export declare abstract class SQLDialect implements SQLParserDialect {
|
|
|
766
702
|
* Used by GenericDatabaseProvider to re-throw connection errors from
|
|
767
703
|
* RunView/RunQuery instead of swallowing them into `{ Success: false }`.
|
|
768
704
|
*/
|
|
769
|
-
|
|
705
|
+
IsConnectionError(e: unknown): boolean;
|
|
770
706
|
/**
|
|
771
707
|
* Returns an IIF/CASE equivalent expression.
|
|
772
708
|
* SQL Server: IIF(condition, trueVal, falseVal)
|
|
773
709
|
* PostgreSQL: CASE WHEN condition THEN trueVal ELSE falseVal END
|
|
774
710
|
*/
|
|
775
|
-
|
|
711
|
+
IIF(condition: string, trueVal: string, falseVal: string): string;
|
|
776
712
|
/**
|
|
777
713
|
* SQL that marks a nested transaction savepoint. SQL Server:
|
|
778
714
|
* `SAVE TRANSACTION name`. PostgreSQL: `SAVEPOINT name`.
|
|
779
715
|
*/
|
|
780
|
-
|
|
716
|
+
CreateSavepointSQL(name: string): string;
|
|
781
717
|
/**
|
|
782
718
|
* SQL that discards a savepoint after a nested commit, or `null` when the
|
|
783
719
|
* platform has no release (SQL Server savepoints live until the outer TX
|
|
784
720
|
* ends). PostgreSQL: `RELEASE SAVEPOINT name`.
|
|
785
721
|
*/
|
|
786
|
-
|
|
722
|
+
ReleaseSavepointSQL(name: string): string | null;
|
|
787
723
|
/**
|
|
788
724
|
* SQL that undoes work after a savepoint. SQL Server:
|
|
789
725
|
* `ROLLBACK TRANSACTION name`. PostgreSQL: `ROLLBACK TO SAVEPOINT name`.
|
|
790
726
|
*/
|
|
791
|
-
|
|
727
|
+
RollbackToSavepointSQL(name: string): string;
|
|
792
728
|
}
|
|
793
729
|
//# sourceMappingURL=sqlDialect.d.ts.map
|