@memberjunction/sql-dialect 6.2.0-edge.6 → 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.
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,105 +1,24 @@
1
- import { SQLDialect, } from './sqlDialect.js';
1
+ import { SQLDialect } from './sqlDialect.js';
2
+ import { ANSI_GRAMMAR, ANSI_LEXICAL, ANSI_WRITE_STATEMENT_KEYWORDS, AnsiWriter } from './dialects/ansi.js';
3
+ import { SQLServerSchemaDDL } from './dialects/sqlServerSchemaDDL.js';
2
4
  /**
3
- * SQL Server-specific data type mapping.
4
- * Maps SQL Server types to themselves (identity mapping) since
5
- * SQL Server is the canonical source type in MemberJunction.
5
+ * SQL Server lexical rules: `[…]` and `"…"` identifiers, `'…'` and `N'…'` strings with doubled
6
+ * quotes, `--` line comments and nested block comments, `@name` parameters.
7
+ *
8
+ * - Identifiers: https://learn.microsoft.com/en-us/sql/relational-databases/databases/database-identifiers
9
+ * - Nested block comments: https://learn.microsoft.com/en-us/sql/t-sql/language-elements/slash-star-comment-transact-sql
10
+ * - `--` comments: https://learn.microsoft.com/en-us/sql/t-sql/language-elements/comment-transact-sql
6
11
  */
7
- class SQLServerDataTypeMap {
8
- MapType(sourceType, sourceLength, sourcePrecision, sourceScale) {
9
- const normalized = sourceType.toUpperCase().trim();
10
- switch (normalized) {
11
- case 'UNIQUEIDENTIFIER':
12
- return { typeName: 'UNIQUEIDENTIFIER', supportsLength: false, supportsPrecisionScale: false };
13
- case 'NVARCHAR':
14
- return this.buildNVarcharType(sourceLength);
15
- case 'VARCHAR':
16
- return this.buildVarcharType(sourceLength);
17
- case 'NCHAR':
18
- case 'CHAR':
19
- return { typeName: normalized, supportsLength: true, supportsPrecisionScale: false, defaultLength: sourceLength ?? 1 };
20
- case 'INT':
21
- case 'INTEGER':
22
- return { typeName: 'INT', supportsLength: false, supportsPrecisionScale: false };
23
- case 'BIGINT':
24
- return { typeName: 'BIGINT', supportsLength: false, supportsPrecisionScale: false };
25
- case 'SMALLINT':
26
- return { typeName: 'SMALLINT', supportsLength: false, supportsPrecisionScale: false };
27
- case 'TINYINT':
28
- return { typeName: 'TINYINT', supportsLength: false, supportsPrecisionScale: false };
29
- case 'BIT':
30
- return { typeName: 'BIT', supportsLength: false, supportsPrecisionScale: false };
31
- case 'DECIMAL':
32
- case 'NUMERIC':
33
- return { typeName: normalized, supportsLength: false, supportsPrecisionScale: true };
34
- case 'FLOAT':
35
- return { typeName: 'FLOAT', supportsLength: false, supportsPrecisionScale: false };
36
- case 'REAL':
37
- return { typeName: 'REAL', supportsLength: false, supportsPrecisionScale: false };
38
- case 'MONEY':
39
- return { typeName: 'MONEY', supportsLength: false, supportsPrecisionScale: false };
40
- case 'SMALLMONEY':
41
- return { typeName: 'SMALLMONEY', supportsLength: false, supportsPrecisionScale: false };
42
- case 'DATE':
43
- return { typeName: 'DATE', supportsLength: false, supportsPrecisionScale: false };
44
- case 'DATETIME':
45
- return { typeName: 'DATETIME', supportsLength: false, supportsPrecisionScale: false };
46
- case 'DATETIME2':
47
- return { typeName: 'DATETIME2', supportsLength: false, supportsPrecisionScale: false };
48
- case 'DATETIMEOFFSET':
49
- return { typeName: 'DATETIMEOFFSET', supportsLength: false, supportsPrecisionScale: false };
50
- case 'SMALLDATETIME':
51
- return { typeName: 'SMALLDATETIME', supportsLength: false, supportsPrecisionScale: false };
52
- case 'TIME':
53
- return { typeName: 'TIME', supportsLength: false, supportsPrecisionScale: false };
54
- case 'TEXT':
55
- case 'NTEXT':
56
- return { typeName: normalized, supportsLength: false, supportsPrecisionScale: false };
57
- case 'IMAGE':
58
- return { typeName: 'IMAGE', supportsLength: false, supportsPrecisionScale: false };
59
- case 'VARBINARY':
60
- return { typeName: 'VARBINARY', supportsLength: true, supportsPrecisionScale: false, defaultLength: sourceLength };
61
- case 'BINARY':
62
- return { typeName: 'BINARY', supportsLength: true, supportsPrecisionScale: false, defaultLength: sourceLength ?? 1 };
63
- case 'XML':
64
- return { typeName: 'XML', supportsLength: false, supportsPrecisionScale: false };
65
- default:
66
- return { typeName: normalized, supportsLength: false, supportsPrecisionScale: false };
67
- }
68
- }
69
- MapTypeToString(sourceType, sourceLength, sourcePrecision, sourceScale) {
70
- const mapped = this.MapType(sourceType, sourceLength, sourcePrecision, sourceScale);
71
- return formatTypeString(mapped, sourceLength, sourcePrecision, sourceScale);
72
- }
73
- buildNVarcharType(length) {
74
- if (length === -1 || length === undefined) {
75
- return { typeName: 'NVARCHAR(MAX)', supportsLength: false, supportsPrecisionScale: false };
76
- }
77
- return { typeName: 'NVARCHAR', supportsLength: true, supportsPrecisionScale: false, defaultLength: length };
78
- }
79
- buildVarcharType(length) {
80
- if (length === -1 || length === undefined) {
81
- return { typeName: 'VARCHAR(MAX)', supportsLength: false, supportsPrecisionScale: false };
82
- }
83
- return { typeName: 'VARCHAR', supportsLength: true, supportsPrecisionScale: false, defaultLength: length };
84
- }
85
- }
86
- /**
87
- * Helper to format a MappedType into a full SQL type string.
88
- */
89
- function formatTypeString(mapped, length, precision, scale) {
90
- if (mapped.supportsPrecisionScale && precision != null) {
91
- return scale != null
92
- ? `${mapped.typeName}(${precision},${scale})`
93
- : `${mapped.typeName}(${precision})`;
94
- }
95
- if (mapped.supportsLength) {
96
- const len = length ?? mapped.defaultLength;
97
- if (len != null) {
98
- return len === -1 ? `${mapped.typeName}(MAX)` : `${mapped.typeName}(${len})`;
99
- }
100
- }
101
- return mapped.typeName;
102
- }
12
+ export const SQL_SERVER_LEXICAL = Object.freeze({
13
+ ...ANSI_LEXICAL,
14
+ IdentifierQuotes: Object.freeze([
15
+ Object.freeze({ Open: '"', Close: '"', DoubledCloseEscape: true }),
16
+ Object.freeze({ Open: '[', Close: ']', DoubledCloseEscape: true }),
17
+ ]),
18
+ BlockComments: Object.freeze({ Nested: true, ExecutableOpeners: Object.freeze([]) }),
19
+ ParameterPlaceholders: Object.freeze(['at-name']),
20
+ UnquotedIdentifierCase: 'none',
21
+ });
103
22
  /**
104
23
  * SQL Server functions caller-supplied SQL may not call: the rowset functions that reach other
105
24
  * servers, databases or files, `OPENXML`, and the functions that read trace, audit and
@@ -109,25 +28,65 @@ const SQL_SERVER_CALLER_SQL_FORBIDDEN_FUNCTIONS = [
109
28
  'openrowset', 'openquery', 'opendatasource', 'openxml',
110
29
  'fn_get_audit_file', 'fn_xe_file_target_read_file', 'fn_trace_gettable'
111
30
  ];
31
+ /** Keywords that begin a T-SQL statement that writes data, changes the schema or runs code. */
32
+ const SQL_SERVER_WRITE_STATEMENT_KEYWORDS = Object.freeze([
33
+ ...ANSI_WRITE_STATEMENT_KEYWORDS.filter(keyword => keyword !== 'CALL'),
34
+ 'EXEC', 'EXECUTE', 'DENY', 'BULK', 'BACKUP', 'RESTORE', 'DBCC', 'RECONFIGURE', 'SHUTDOWN', 'KILL',
35
+ ]);
112
36
  /**
113
- * SQL Server dialect implementation.
114
- * Uses [bracket] quoting, TOP for pagination, BIT for booleans, T-SQL functions.
37
+ * Reserved T-SQL keywords that only ever begin a statement. T-SQL needs no separator between
38
+ * statements, so one of these as a bare word after a statement's first word starts another
39
+ * statement in the same batch.
115
40
  */
116
- export class SQLServerDialect extends SQLDialect {
117
- get PlatformKey() {
118
- return 'sqlserver';
119
- }
120
- get ParserDialect() {
121
- return 'TransactSQL';
122
- }
123
- get DisplayName() {
124
- return 'Microsoft SQL Server (T-SQL)';
125
- }
126
- /** `sql-formatter` ships T-SQL under the `tsql` language key. */
127
- get FormatterLanguage() {
128
- return 'tsql';
129
- }
130
- // ─── Identifier Quoting ──────────────────────────────────────────
41
+ const SQL_SERVER_STATEMENT_KEYWORDS = [
42
+ 'SET', 'DECLARE', 'WAITFOR', 'USE', 'PRINT', 'RAISERROR', 'BEGIN', 'COMMIT', 'ROLLBACK', 'SAVE', 'GOTO', 'RETURN',
43
+ 'IF', 'WHILE', 'BREAK', 'CONTINUE', 'OPEN', 'CLOSE', 'DEALLOCATE', 'CHECKPOINT', 'READTEXT', 'WRITETEXT', 'UPDATETEXT',
44
+ ];
45
+ /**
46
+ * SQL Server grammar facts: `TOP` and `OFFSET … FETCH` row caps, no ORDER BY in a CTE or derived
47
+ * table without TOP/OFFSET/FOR XML, no nested WITH, plain `WITH` for recursion, the `OPTION (…)`
48
+ * hint clause, `FOR JSON` / `FOR XML`, `CROSS/OUTER APPLY`.
49
+ */
50
+ export const SQL_SERVER_GRAMMAR = Object.freeze({
51
+ ...ANSI_GRAMMAR,
52
+ ParserGrammar: 'TransactSQL',
53
+ DefaultSchema: 'dbo',
54
+ RowCapForms: Object.freeze(['top', 'offset-fetch']),
55
+ AllowsOrderByInCTE: false,
56
+ AllowsOrderByInDerivedTable: false,
57
+ SupportsNestedWith: false,
58
+ RecursiveKeyword: null,
59
+ QueryHintKeyword: 'OPTION',
60
+ DocumentTailClauses: Object.freeze(['FOR JSON', 'FOR XML']),
61
+ CorrelatedJoin: 'apply',
62
+ WriteStatementKeywords: SQL_SERVER_WRITE_STATEMENT_KEYWORDS,
63
+ CallerSQLForbiddenFunctions: SQL_SERVER_CALLER_SQL_FORBIDDEN_FUNCTIONS,
64
+ UnseparatedStatementKeywords: Object.freeze([...SQL_SERVER_WRITE_STATEMENT_KEYWORDS, ...SQL_SERVER_STATEMENT_KEYWORDS]),
65
+ DefaultPagingOrderBy: '(SELECT NULL)',
66
+ SelectListPagingOrderBy: '1',
67
+ PagingRequiresOrderBy: true,
68
+ ExtraColumnAliasForms: Object.freeze(['equals', 'string']),
69
+ });
70
+ /**
71
+ * SQL Server's column-type names as they appear in `sys.columns.name` / `EntityField.Type` for
72
+ * entities backed by a SQL Server schema. `char` and `nchar` right-pad stored values with spaces.
73
+ */
74
+ export const SQL_SERVER_TYPES = Object.freeze({
75
+ BooleanTypeNames: Object.freeze(['bit']),
76
+ StringTypeNames: Object.freeze(['text', 'ntext', 'varchar', 'nvarchar', 'char', 'nchar']),
77
+ FixedWidthStringTypeNames: Object.freeze(['char', 'nchar']),
78
+ DateTypeNames: Object.freeze(['date', 'time', 'datetime', 'datetime2', 'datetimeoffset', 'smalldatetime']),
79
+ IntegerTypeNames: Object.freeze(['int', 'integer', 'bigint', 'smallint', 'tinyint', 'rowversion', 'timestamp']),
80
+ FloatTypeNames: Object.freeze(['decimal', 'numeric', 'float', 'real']),
81
+ UuidTypeNames: Object.freeze(['uniqueidentifier']),
82
+ BinaryTypeNames: Object.freeze(['binary', 'varbinary', 'image']),
83
+ JsonTypeNames: Object.freeze(['xml']),
84
+ CurrencyTypeNames: Object.freeze(['money', 'smallmoney']),
85
+ IntervalTypeNames: Object.freeze([]),
86
+ NetworkTypeNames: Object.freeze([]),
87
+ });
88
+ /** Writes T-SQL: bracket quoting, `TOP`, `BIT` booleans, `ISNULL`, `+` concatenation. */
89
+ export class SQLServerWriter extends AnsiWriter {
131
90
  QuoteIdentifier(name) {
132
91
  // Double embedded closing brackets so a name containing `]` cannot terminate the
133
92
  // quoting early (mirrors the PostgreSQL dialect's doubling of embedded `"`).
@@ -144,30 +103,15 @@ export class SQLServerDialect extends SQLDialect {
144
103
  QuoteColumnAlias(aliasName) {
145
104
  return aliasName;
146
105
  }
147
- /** SQL Server is case-insensitive for identifiers; the schema name is stored as-given. */
148
- CanonicalSchemaName(name) {
149
- return name;
150
- }
151
- // ─── Pagination ──────────────────────────────────────────────────
152
106
  LimitClause(limit, offset) {
153
107
  if (offset != null) {
154
108
  return { prefix: '', suffix: `OFFSET ${offset} ROWS FETCH NEXT ${limit} ROWS ONLY` };
155
109
  }
156
110
  return { prefix: `TOP ${limit}`, suffix: '' };
157
111
  }
158
- // ─── Literals & Expressions ──────────────────────────────────────
159
112
  BooleanLiteral(value) {
160
113
  return value ? '1' : '0';
161
114
  }
162
- BooleanParameterType() {
163
- return 'bit';
164
- }
165
- ParameterRef(name) {
166
- return `@${name}`;
167
- }
168
- ParameterDefault(value) {
169
- return ` = ${value}`;
170
- }
171
115
  /**
172
116
  * SQL Server has both `ISNULL` (T-SQL native, two-arg only) and `COALESCE`
173
117
  * (ANSI, n-ary). For two-argument null-coalescing we emit the native
@@ -190,500 +134,86 @@ export class SQLServerDialect extends SQLDialect {
190
134
  CurrentTimestampUTC() {
191
135
  return 'GETUTCDATE()';
192
136
  }
193
- AffectedRowCountSQL(dmlStatement, alias) {
194
- return `${dmlStatement};\nSELECT @@ROWCOUNT AS ${this.QuoteColumnAlias(alias)}`;
195
- }
196
- // ─── Type-Name Sets ──────────────────────────────────────────────
197
- // SQL Server's column-type names as they appear in `sys.columns.name`
198
- // / `EntityField.Type` for entities backed by a SQL Server schema.
199
- static { this._booleanTypeNames = ['bit']; }
200
- static { this._stringTypeNames = ['text', 'ntext', 'varchar', 'nvarchar', 'char', 'nchar']; }
201
- /** `char` and `nchar` right-pad stored values with spaces up to declared length. */
202
- static { this._fixedWidthStringTypeNames = ['char', 'nchar']; }
203
- static { this._dateTypeNames = ['date', 'time', 'datetime', 'datetime2', 'datetimeoffset', 'smalldatetime']; }
204
- static { this._integerTypeNames = ['int', 'integer', 'bigint', 'smallint', 'tinyint', 'rowversion', 'timestamp']; }
205
- static { this._floatTypeNames = ['decimal', 'numeric', 'float', 'real']; }
206
- static { this._uuidTypeNames = ['uniqueidentifier']; }
207
- static { this._binaryTypeNames = ['binary', 'varbinary', 'image']; }
208
- static { this._jsonTypeNames = ['xml']; }
209
- static { this._currencyTypeNames = ['money', 'smallmoney']; }
210
- static { this._intervalTypeNames = []; }
211
- static { this._networkTypeNames = []; }
212
- get BooleanTypeNames() { return SQLServerDialect._booleanTypeNames; }
213
- get StringTypeNames() { return SQLServerDialect._stringTypeNames; }
214
- get FixedWidthStringTypeNames() { return SQLServerDialect._fixedWidthStringTypeNames; }
215
- /** SQL Server index keys are limited to 900 bytes → 450 NVARCHAR (2-byte) chars. */
216
- get MaxKeyStringLength() { return 450; }
217
- /** SQL Server enforces a hard ~8060-byte in-row row size; only variable-length values go off-row. */
218
- get MaxInRowSizeBytes() { return 8060; }
219
- /** SQL Server's hard per-table column cap. */
220
- get MaxColumnCount() { return 1024; }
221
- /**
222
- * Minimum in-row byte footprint of a column. Off-row-capable variable-length / LOB types
223
- * (incl. `(N)VARCHAR(MAX)`) contribute only a 24-byte in-row pointer; fixed-length types
224
- * contribute their full size. Unknown types are treated as off-row pointers (conservative).
225
- */
226
- EstimateInRowBytes(rawSqlType) {
227
- const t = (rawSqlType ?? '').toUpperCase().trim();
228
- // Off-row-capable variable-length + LOB types → 24-byte in-row pointer floor.
229
- if (/^(N?VARCHAR|VARBINARY)\s*\(/.test(t))
230
- return 24; // covers (N)VARCHAR(MAX) too
231
- if (/^(TEXT|NTEXT|IMAGE|XML|SQL_VARIANT)\b/.test(t))
232
- return 24;
233
- // Fixed-length character/binary types stay fully in-row.
234
- const nchar = t.match(/^NCHAR\s*\(\s*(\d+)\s*\)/);
235
- if (nchar)
236
- return parseInt(nchar[1], 10) * 2;
237
- const chr = t.match(/^(?:CHAR|BINARY)\s*\(\s*(\d+)\s*\)/);
238
- if (chr)
239
- return parseInt(chr[1], 10);
240
- if (/^UNIQUEIDENTIFIER\b/.test(t))
241
- return 16;
242
- if (/^BIGINT\b/.test(t))
243
- return 8;
244
- if (/^SMALLINT\b/.test(t))
245
- return 2;
246
- if (/^TINYINT\b/.test(t))
247
- return 1;
248
- if (/^INT\b/.test(t))
249
- return 4;
250
- if (/^BIT\b/.test(t))
251
- return 1;
252
- if (/^(DECIMAL|NUMERIC|MONEY|SMALLMONEY)\b/.test(t))
253
- return 17;
254
- if (/^(FLOAT|REAL)\b/.test(t))
255
- return 8;
256
- if (/^DATETIMEOFFSET\b/.test(t))
257
- return 10;
258
- if (/^(DATETIME2|DATETIME|SMALLDATETIME)\b/.test(t))
259
- return 8;
260
- if (/^DATE\b/.test(t))
261
- return 3;
262
- if (/^TIME\b/.test(t))
263
- return 5;
264
- return 24; // unknown → treat as off-row variable-length pointer (conservative)
265
- }
266
- get DateTypeNames() { return SQLServerDialect._dateTypeNames; }
267
- get IntegerTypeNames() { return SQLServerDialect._integerTypeNames; }
268
- get FloatTypeNames() { return SQLServerDialect._floatTypeNames; }
269
- get UuidTypeNames() { return SQLServerDialect._uuidTypeNames; }
270
- get BinaryTypeNames() { return SQLServerDialect._binaryTypeNames; }
271
- get JsonTypeNames() { return SQLServerDialect._jsonTypeNames; }
272
- get CurrencyTypeNames() { return SQLServerDialect._currencyTypeNames; }
273
- get IntervalTypeNames() { return SQLServerDialect._intervalTypeNames; }
274
- get NetworkTypeNames() { return SQLServerDialect._networkTypeNames; }
275
- NewUUID() {
276
- return 'NEWID()';
277
- }
278
137
  CastToText(expr) {
279
138
  return `CAST(${expr} AS NVARCHAR(MAX))`;
280
139
  }
281
- /**
282
- * SQL Server-specific Flyway escape. Interleaves a `CAST(N'' AS NVARCHAR(MAX))`
283
- * between the split halves so the running T-SQL concat chain inherits
284
- * NVARCHAR(MAX) precedence. Without the cast, `N'a' + N'b'` produces
285
- * NVARCHAR(a+b) capped at NVARCHAR(4000) and silently truncates anything
286
- * past 4,000 characters.
287
- */
288
- EscapeFlywayStringInterpolation(sql) {
289
- return sql.replaceAll(/\$\{/g, "$$'+CAST(N'' AS NVARCHAR(MAX))+N'{");
290
- }
291
- CastToUUID(expr) {
292
- return `CAST(${expr} AS UNIQUEIDENTIFIER)`;
293
- }
294
- // ─── INSERT/UPDATE Return Patterns ───────────────────────────────
295
- ReturnInsertedClause(columns) {
296
- if (columns && columns.length > 0) {
297
- const cols = columns.map(c => `INSERTED.[${c}]`).join(', ');
298
- return `OUTPUT ${cols}`;
299
- }
300
- return 'OUTPUT INSERTED.*';
301
- }
302
- AutoIncrementPKExpression() {
303
- return 'IDENTITY(1,1)';
304
- }
305
- UUIDPKDefault() {
306
- return 'NEWSEQUENTIALID()';
307
- }
308
- ScopeIdentityExpression() {
309
- return 'SCOPE_IDENTITY()';
310
- }
311
- RowCountExpression() {
312
- return '@@ROWCOUNT';
313
- }
314
- // ─── Batch & DDL Control ─────────────────────────────────────────
315
- BatchSeparator() {
316
- return 'GO';
317
- }
318
- CreateSavepointSQL(name) {
319
- return `SAVE TRANSACTION ${name}`;
320
- }
321
- ReleaseSavepointSQL(_name) {
322
- return null;
323
- }
324
- RollbackToSavepointSQL(name) {
325
- return `ROLLBACK TRANSACTION ${name}`;
326
- }
327
- ExistenceCheckSQL(objectType, schema, name) {
328
- const normalizedType = objectType.toUpperCase();
329
- switch (normalizedType) {
330
- case 'TABLE':
331
- return `IF OBJECT_ID('[${schema}].[${name}]', 'U') IS NOT NULL`;
332
- case 'VIEW':
333
- return `IF OBJECT_ID('[${schema}].[${name}]', 'V') IS NOT NULL`;
334
- case 'PROCEDURE':
335
- return `IF OBJECT_ID('[${schema}].[${name}]', 'P') IS NOT NULL`;
336
- case 'FUNCTION':
337
- return `IF OBJECT_ID('[${schema}].[${name}]', 'FN') IS NOT NULL`;
338
- case 'TRIGGER':
339
- return `IF OBJECT_ID('[${schema}].[${name}]', 'TR') IS NOT NULL`;
340
- default:
341
- return `IF OBJECT_ID('[${schema}].[${name}]') IS NOT NULL`;
342
- }
343
- }
344
- CreateOrReplaceSupported(_objectType) {
345
- return false; // SQL Server does not support CREATE OR REPLACE
346
- }
347
- // ─── Full-Text Search ────────────────────────────────────────────
348
- FullTextSearchPredicate(column, searchTerm) {
349
- return `CONTAINS(${this.QuoteIdentifier(column)}, ${searchTerm})`;
350
- }
351
- FullTextIndexDDL(table, columns, catalog) {
352
- const catName = catalog ?? 'MJ_FTS';
353
- const cols = columns.map(c => this.QuoteIdentifier(c)).join(', ');
354
- const lines = [];
355
- lines.push(`IF NOT EXISTS (SELECT 1 FROM sys.fulltext_catalogs WHERE name = '${catName}')`);
356
- lines.push(` CREATE FULLTEXT CATALOG [${catName}];`);
357
- lines.push('');
358
- lines.push(`CREATE FULLTEXT INDEX ON ${table}(${cols})`);
359
- lines.push(` KEY INDEX PK_${table.replace(/[\[\].]/g, '')} ON [${catName}];`);
360
- return lines.join('\n');
361
- }
362
- // ─── CTE / Recursion ─────────────────────────────────────────────
363
- RecursiveCTESyntax() {
364
- return 'WITH';
365
- }
366
- get AllowsOrderByInCTE() {
367
- return false;
368
- }
369
- get DefaultPagingOrderBy() {
370
- return '(SELECT NULL)';
371
- }
372
- get SelectListPagingOrderBy() {
373
- return '1';
374
- }
375
- get PagingRequiresOrderBy() {
376
- return true;
377
- }
378
- get SupportsEscapeStringLiterals() {
379
- return false;
380
- }
381
- get SupportsDollarQuotedStrings() {
382
- return false;
383
- }
384
- get QueryHintKeyword() {
385
- return 'OPTION';
386
- }
387
- get CallerSQLForbiddenFunctions() {
388
- return SQL_SERVER_CALLER_SQL_FORBIDDEN_FUNCTIONS;
389
- }
390
140
  StringLiteralPrefix(text) {
391
141
  return /[^\x00-\x7F]/.test(text) ? 'N' : '';
392
142
  }
393
143
  EscapeLikePattern(text) {
394
144
  return text.replace(/\[/g, '[[]').replace(/%/g, '[%]').replace(/_/g, '[_]');
395
145
  }
396
- BooleanParameterValue(value) {
397
- return value ? 1 : 0;
398
- }
399
- // ─── Data Types ──────────────────────────────────────────────────
400
- get TypeMap() {
401
- return new SQLServerDataTypeMap();
402
- }
403
- // ─── Parameters ──────────────────────────────────────────────────
404
- ParameterPlaceholder(index) {
405
- return `@p${index}`;
406
- }
407
146
  ConcatOperator() {
408
147
  return '+';
409
148
  }
410
- // ─── String Functions ────────────────────────────────────────────
411
- StringSplitFunction(value, delimiter) {
412
- return `STRING_SPLIT(${value}, ${delimiter})`;
413
- }
414
149
  JsonExtract(column, path) {
415
150
  return `JSON_VALUE(${column}, '${path}')`;
416
151
  }
417
- // ─── Procedure / Function Calls ──────────────────────────────────
418
- ProcedureCallSyntax(schema, name, params) {
419
- const paramList = params.join(', ');
420
- return `EXEC [${schema}].[${name}] ${paramList}`;
421
- }
422
- // ─── DDL Generation (Schema/Table) ──────────────────────────────
423
- CreateSchemaDDL(schemaName) {
424
- return `IF NOT EXISTS (SELECT 1 FROM sys.schemas WHERE name = '${schemaName}')\n EXEC('CREATE SCHEMA [${schemaName}]');\nGO`;
425
- }
426
- /** SQL Server cannot index NVARCHAR(MAX) columns — cap to NVARCHAR(450). */
427
- CapIndexableType(rawSqlType) {
428
- return rawSqlType.toUpperCase() === 'NVARCHAR(MAX)' ? 'NVARCHAR(450)' : rawSqlType;
429
- }
430
- // ─── DDL Generation (Conditional/Procedural) ────────────────────
431
152
  DateAddExpression(unit, amount, baseExpr) {
432
153
  return `DATEADD(${unit}, ${amount}, ${baseExpr})`;
433
154
  }
434
- CreateTableIfNotExistsDDL(schema, tableName, columnsDDL) {
435
- const quotedTable = this.QuoteSchema(schema, tableName);
436
- return [
437
- `IF NOT EXISTS (SELECT * FROM sys.tables t JOIN sys.schemas s ON t.schema_id = s.schema_id WHERE s.name='${schema}' AND t.name='${tableName}')`,
438
- `BEGIN`,
439
- ` CREATE TABLE ${quotedTable} (`,
440
- columnsDDL,
441
- ` );`,
442
- `END;`,
443
- ].join('\n');
444
- }
445
- ConditionalBlock(condition, thenSQL, elseSQL) {
446
- const lines = [
447
- `IF ${condition}`,
448
- `BEGIN`,
449
- ` ${thenSQL}`,
450
- `END`,
451
- ];
452
- if (elseSQL) {
453
- lines.push(`ELSE`);
454
- lines.push(`BEGIN`);
455
- lines.push(` ${elseSQL}`);
456
- lines.push(`END`);
457
- }
458
- return lines.join('\n');
459
- }
460
- RaiseSignalSQL(message) {
461
- return `RAISERROR('${message}', 16, 1)`;
462
- }
463
- // ─── DDL Generation (Schema/Table continued) ────────────────────
464
- AddColumnClause(col) {
465
- const nullable = col.nullable ? 'NULL' : 'NOT NULL';
466
- const defaultExpr = col.defaultValue != null ? ` DEFAULT ${col.defaultValue}` : '';
467
- return `ADD [${col.name}] ${col.sqlType} ${nullable}${defaultExpr}`;
468
- }
469
- AlterColumnDDL(quotedTable, options) {
470
- const nullable = options.newNullable ? 'NULL' : 'NOT NULL';
471
- return `ALTER TABLE ${quotedTable}\n ALTER COLUMN [${options.columnName}] ${options.newType} ${nullable};`;
472
- }
473
- CommentOnColumn(schema, table, column, comment) {
474
- const escaped = comment.replace(/'/g, "''");
475
- return [
476
- `EXEC sp_addextendedproperty`,
477
- ` @name = N'MS_Description',`,
478
- ` @value = N'${escaped}',`,
479
- ` @level0type = N'SCHEMA', @level0name = '${schema}',`,
480
- ` @level1type = N'TABLE', @level1name = '${table}',`,
481
- ` @level2type = N'COLUMN', @level2name = '${column}';`,
482
- ].join('\n');
483
- }
484
- FallbackType() {
485
- return 'NVARCHAR(MAX)';
486
- }
487
- // ─── DDL Generation (Triggers/Indexes) ──────────────────────────
488
- TriggerDDL(options) {
489
- const events = options.events.join(', ');
490
- const lines = [];
491
- lines.push(`CREATE TRIGGER [${options.schema}].[${options.triggerName}]`);
492
- lines.push(`ON [${options.schema}].[${options.tableName}]`);
493
- lines.push(`${options.timing} ${events}`);
494
- lines.push('AS');
495
- lines.push('BEGIN');
496
- lines.push(' SET NOCOUNT ON;');
497
- lines.push(` ${options.body}`);
498
- lines.push('END');
499
- return lines.join('\n');
155
+ IIF(condition, trueVal, falseVal) {
156
+ return `IIF(${condition}, ${trueVal}, ${falseVal})`;
500
157
  }
501
- IndexDDL(options) {
502
- const unique = options.unique ? 'UNIQUE ' : '';
503
- const cols = options.columns.map(c => `[${c}]`).join(', ');
504
- let ddl = `CREATE ${unique}INDEX [${options.indexName}] ON [${options.schema}].[${options.tableName}](${cols})`;
505
- if (options.includeColumns && options.includeColumns.length > 0) {
506
- const inc = options.includeColumns.map(c => `[${c}]`).join(', ');
507
- ddl += ` INCLUDE (${inc})`;
508
- }
509
- return ddl;
158
+ }
159
+ /** SQL Server binding through the `mssql` driver: `@p0` placeholders, `1`/`0` booleans. */
160
+ export class SQLServerBinding {
161
+ BooleanParameterValue(value) {
162
+ return value ? 1 : 0;
510
163
  }
511
- // ─── Permissions ─────────────────────────────────────────────────
512
- GrantPermission(permission, _objectType, schema, object, role) {
513
- return `GRANT ${permission} ON [${schema}].[${object}] TO [${role}]`;
164
+ ParameterPlaceholder(index) {
165
+ return `@p${index}`;
514
166
  }
515
- CommentOnObject(objectType, schema, name, comment) {
516
- const escapedComment = comment.replace(/'/g, "''");
517
- const level1Type = this.objectTypeToLevel1Type(objectType);
518
- return [
519
- `EXEC sp_addextendedproperty`,
520
- ` @name = N'MS_Description',`,
521
- ` @value = N'${escapedComment}',`,
522
- ` @level0type = N'SCHEMA', @level0name = N'${schema}',`,
523
- ` @level1type = N'${level1Type}', @level1name = N'${name}'`,
524
- ].join('\n');
167
+ /** A named `@mj_p<n>` parameter; the driver declares its type, so no cast is written. */
168
+ TypedParameter(index, _sqlType) {
169
+ return { Placeholder: `@mj_p${index}`, Name: `mj_p${index}` };
525
170
  }
526
- // ─── Idempotent (single-statement) DDL — see SQLDialect base ─────
527
- CreateTableIfAbsent(fullTable, columnsBody) {
528
- // Single-statement IF guard (no BEGIN/END) so migration chunkers that split on ';\n'
529
- // boundaries cannot separate the guard from the CREATE. The only ';' is the terminating ');'.
530
- return `IF OBJECT_ID(N'${fullTable}', N'U') IS NULL\nCREATE TABLE ${fullTable} (\n${columnsBody}\n);`;
171
+ IsConnectionError(e) {
172
+ if (!(e instanceof Error))
173
+ return false;
174
+ // mssql driver sets error.name to 'ConnectionError' for all connectivity
175
+ // failures (timeout, refused, reset, TLS handshake, etc.)
176
+ return e.name === 'ConnectionError';
531
177
  }
532
- CommentOnObjectIfAbsent(objectType, schema, name, comment) {
533
- const level1Type = this.objectTypeToLevel1Type(objectType);
534
- // IF NOT EXISTS governs the single EXEC that follows (sp_addextendedproperty has no internal ';').
535
- return [
536
- `IF NOT EXISTS (SELECT 1 FROM sys.fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'${schema}', N'${level1Type}', N'${name}', NULL, NULL))`,
537
- `${this.CommentOnObject(objectType, schema, name, comment)};`,
538
- ].join('\n');
178
+ }
179
+ /**
180
+ * SQL Server dialect implementation.
181
+ * Uses [bracket] quoting, TOP for pagination, BIT for booleans, T-SQL functions.
182
+ */
183
+ export class SQLServerDialect extends SQLDialect {
184
+ constructor() {
185
+ super(...arguments);
186
+ this.writer = Object.freeze(new SQLServerWriter());
187
+ this.binding = Object.freeze(new SQLServerBinding());
188
+ this.ddl = Object.freeze(new SQLServerSchemaDDL(this.writer));
539
189
  }
540
- CommentOnColumnIfAbsent(schema, table, column, comment) {
541
- return [
542
- `IF NOT EXISTS (SELECT 1 FROM sys.fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'${schema}', N'TABLE', N'${table}', N'COLUMN', N'${column}'))`,
543
- this.CommentOnColumn(schema, table, column, comment),
544
- ].join('\n');
190
+ get PlatformKey() {
191
+ return 'sqlserver';
545
192
  }
546
- // ─── Schema Introspection ────────────────────────────────────────
547
- SchemaIntrospectionQueries() {
548
- return {
549
- listTables: `
550
- SELECT s.name AS schema_name, t.name AS table_name
551
- FROM sys.tables t
552
- INNER JOIN sys.schemas s ON t.schema_id = s.schema_id
553
- WHERE s.name = @schema
554
- ORDER BY t.name`,
555
- listColumns: `
556
- SELECT c.name AS column_name, ty.name AS data_type,
557
- c.max_length, c.precision, c.scale, c.is_nullable,
558
- c.is_identity, dc.definition AS default_value
559
- FROM sys.columns c
560
- INNER JOIN sys.types ty ON c.user_type_id = ty.user_type_id
561
- LEFT JOIN sys.default_constraints dc ON c.default_object_id = dc.object_id
562
- WHERE c.object_id = OBJECT_ID(@table)
563
- ORDER BY c.column_id`,
564
- listConstraints: `
565
- SELECT tc.CONSTRAINT_NAME, tc.CONSTRAINT_TYPE, kcu.COLUMN_NAME
566
- FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS tc
567
- INNER JOIN INFORMATION_SCHEMA.KEY_COLUMN_USAGE kcu
568
- ON tc.CONSTRAINT_NAME = kcu.CONSTRAINT_NAME
569
- WHERE tc.TABLE_SCHEMA = @schema AND tc.TABLE_NAME = @table
570
- ORDER BY tc.CONSTRAINT_TYPE, kcu.ORDINAL_POSITION`,
571
- listForeignKeys: `
572
- SELECT fk.name AS fk_name,
573
- OBJECT_SCHEMA_NAME(fk.parent_object_id) AS source_schema,
574
- OBJECT_NAME(fk.parent_object_id) AS source_table,
575
- COL_NAME(fkc.parent_object_id, fkc.parent_column_id) AS source_column,
576
- OBJECT_SCHEMA_NAME(fk.referenced_object_id) AS target_schema,
577
- OBJECT_NAME(fk.referenced_object_id) AS target_table,
578
- COL_NAME(fkc.referenced_object_id, fkc.referenced_column_id) AS target_column
579
- FROM sys.foreign_keys fk
580
- INNER JOIN sys.foreign_key_columns fkc ON fk.object_id = fkc.constraint_object_id
581
- WHERE OBJECT_SCHEMA_NAME(fk.parent_object_id) = @schema
582
- ORDER BY fk.name`,
583
- listIndexes: `
584
- SELECT i.name AS index_name, i.is_unique, i.type_desc,
585
- COL_NAME(ic.object_id, ic.column_id) AS column_name,
586
- ic.is_included_column
587
- FROM sys.indexes i
588
- INNER JOIN sys.index_columns ic ON i.object_id = ic.object_id AND i.index_id = ic.index_id
589
- WHERE i.object_id = OBJECT_ID(@table) AND i.name IS NOT NULL
590
- ORDER BY i.name, ic.key_ordinal`,
591
- objectExists: `SELECT OBJECT_ID(@objectName) AS object_id`,
592
- };
193
+ get DisplayName() {
194
+ return 'Microsoft SQL Server (T-SQL)';
593
195
  }
594
- /**
595
- * SQL Server FK-graph query for cascade planning — reads the `sys.foreign_keys` catalog.
596
- * Returns one row per FK column with `childNullable` (from `sys.columns.is_nullable`) and
597
- * `colCount` (columns in the constraint, for composite exclusion). Both parent + child are
598
- * filtered to `schema`. Schema is embedded as a literal (no bind params) so it runs via
599
- * `ExecuteSQL(sql)`.
600
- */
601
- ForeignKeyGraphSQL(schema) {
602
- const s = this.QuoteStringLiteral(schema);
603
- // Disabled FKs (fk.is_disabled = 1) are intentionally NOT filtered: a disabled FK can't block
604
- // the Entity delete, so including it only yields an extra, conservative-safe child clear.
605
- // ORDER BY fk.name makes edge order — and therefore statement + dry-run order — deterministic.
606
- return ('SELECT rt.name AS parentTable, rc.name AS parentRefCol, pt.name AS childTable, ' +
607
- 'pc.name AS childCol, pc.is_nullable AS childNullable, fk.name AS fkName, ' +
608
- '(SELECT COUNT(*) FROM sys.foreign_key_columns x WHERE x.constraint_object_id = fk.object_id) AS colCount ' +
609
- 'FROM sys.foreign_keys fk ' +
610
- 'JOIN sys.foreign_key_columns fkc ON fkc.constraint_object_id = fk.object_id ' +
611
- 'JOIN sys.objects rt ON rt.object_id = fk.referenced_object_id ' +
612
- 'JOIN sys.schemas rs ON rs.schema_id = rt.schema_id ' +
613
- 'JOIN sys.columns rc ON rc.object_id = fk.referenced_object_id AND rc.column_id = fkc.referenced_column_id ' +
614
- 'JOIN sys.objects pt ON pt.object_id = fk.parent_object_id ' +
615
- 'JOIN sys.schemas ps ON ps.schema_id = pt.schema_id ' +
616
- 'JOIN sys.columns pc ON pc.object_id = fk.parent_object_id AND pc.column_id = fkc.parent_column_id ' +
617
- `WHERE rs.name = ${s} AND ps.name = ${s} ` +
618
- 'ORDER BY fk.name');
196
+ /** `sql-formatter` ships T-SQL under the `tsql` language key. */
197
+ get FormatterLanguage() {
198
+ return 'tsql';
619
199
  }
620
- AtomicBatchScript(statements) {
621
- if (!statements || !statements.length)
622
- return '';
623
- const body = statements.join(';\n');
624
- return `SET QUOTED_IDENTIFIER ON;\nSET ANSI_NULLS ON;\nSET XACT_ABORT ON;\nBEGIN TRANSACTION;\n${body};\nCOMMIT TRANSACTION;`;
200
+ get Lexical() {
201
+ return SQL_SERVER_LEXICAL;
625
202
  }
626
- // ─── IIF ─────────────────────────────────────────────────────────
627
- IIF(condition, trueVal, falseVal) {
628
- return `IIF(${condition}, ${trueVal}, ${falseVal})`;
203
+ get Grammar() {
204
+ return SQL_SERVER_GRAMMAR;
629
205
  }
630
- // ─── Abstract Type Resolution ─────────────────────────────────────
631
- ResolveAbstractType(options) {
632
- switch (options.type) {
633
- case 'string':
634
- return this.resolveStringType(options.maxLength);
635
- case 'text':
636
- return 'NVARCHAR(MAX)';
637
- case 'integer':
638
- return 'INT';
639
- case 'bigint':
640
- return 'BIGINT';
641
- case 'decimal':
642
- return `DECIMAL(${options.precision ?? 18},${options.scale ?? 2})`;
643
- case 'boolean':
644
- return 'BIT';
645
- case 'datetime':
646
- return 'DATETIMEOFFSET';
647
- case 'date':
648
- return 'DATE';
649
- case 'uuid':
650
- return 'UNIQUEIDENTIFIER';
651
- case 'json':
652
- return 'NVARCHAR(MAX)';
653
- case 'float':
654
- return 'FLOAT';
655
- case 'time':
656
- return 'TIME';
657
- default:
658
- return this.FallbackType();
659
- }
206
+ get Writer() {
207
+ return this.writer;
660
208
  }
661
- // ─── Error Classification ────────────────────────────────────────
662
- IsConnectionError(e) {
663
- if (!(e instanceof Error))
664
- return false;
665
- // mssql driver sets error.name to 'ConnectionError' for all connectivity
666
- // failures (timeout, refused, reset, TLS handshake, etc.)
667
- return e.name === 'ConnectionError';
209
+ get Types() {
210
+ return SQL_SERVER_TYPES;
668
211
  }
669
- // ─── Private Helpers ────────────────────────────────────────────
670
- resolveStringType(maxLength) {
671
- if (maxLength != null && maxLength > 0) {
672
- if (maxLength > 4000)
673
- return 'NVARCHAR(MAX)';
674
- return `NVARCHAR(${maxLength})`;
675
- }
676
- return 'NVARCHAR(255)';
212
+ get Binding() {
213
+ return this.binding;
677
214
  }
678
- // ─── Private Helpers ─────────────────────────────────────────────
679
- objectTypeToLevel1Type(objectType) {
680
- switch (objectType.toUpperCase()) {
681
- case 'TABLE': return 'TABLE';
682
- case 'VIEW': return 'VIEW';
683
- case 'PROCEDURE': return 'PROCEDURE';
684
- case 'FUNCTION': return 'FUNCTION';
685
- default: return objectType.toUpperCase();
686
- }
215
+ get DDL() {
216
+ return this.ddl;
687
217
  }
688
218
  }
689
219
  //# sourceMappingURL=sqlServerDialect.js.map