pgsql-deparser 17.17.2 → 17.18.1
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/deparser.js +220 -206
- package/esm/deparser.js +25 -11
- package/esm/index.js +1 -1
- package/index.d.ts +1 -1
- package/index.js +2 -2
- package/package.json +4 -4
- package/esm/kwlist.js +0 -531
- package/esm/utils/quote-utils.js +0 -240
- package/kwlist.d.ts +0 -16
- package/kwlist.js +0 -535
- package/utils/quote-utils.d.ts +0 -87
- package/utils/quote-utils.js +0 -244
package/deparser.js
CHANGED
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.Deparser = void 0;
|
|
4
4
|
const base_1 = require("./visitors/base");
|
|
5
5
|
const sql_formatter_1 = require("./utils/sql-formatter");
|
|
6
|
-
const
|
|
6
|
+
const quotes_1 = require("@pgsql/quotes");
|
|
7
7
|
const list_utils_1 = require("./utils/list-utils");
|
|
8
8
|
/**
|
|
9
9
|
* List of real PostgreSQL built-in types as they appear in pg_catalog.pg_type.typname.
|
|
@@ -508,9 +508,7 @@ class Deparser {
|
|
|
508
508
|
output.push('VALUES');
|
|
509
509
|
const lists = list_utils_1.ListUtils.unwrapList(node.valuesLists).map(list => {
|
|
510
510
|
const values = list_utils_1.ListUtils.unwrapList(list).map(val => this.visit(val, context));
|
|
511
|
-
|
|
512
|
-
const indentedValues = values.map(val => context.indent(val));
|
|
513
|
-
return '(\n' + indentedValues.join(',\n') + '\n)';
|
|
511
|
+
return context.parens(values.join(', '));
|
|
514
512
|
});
|
|
515
513
|
const indentedTuples = lists.map(tuple => {
|
|
516
514
|
if (this.containsMultilineStringLiteral(tuple)) {
|
|
@@ -1200,12 +1198,12 @@ class Deparser {
|
|
|
1200
1198
|
ResTarget(node, context) {
|
|
1201
1199
|
const output = [];
|
|
1202
1200
|
if (context.update && node.name) {
|
|
1203
|
-
output.push(
|
|
1201
|
+
output.push(quotes_1.QuoteUtils.quoteIdentifier(node.name));
|
|
1204
1202
|
// Handle indirection (array indexing, field access, etc.)
|
|
1205
1203
|
if (node.indirection && node.indirection.length > 0) {
|
|
1206
1204
|
const indirectionStrs = list_utils_1.ListUtils.unwrapList(node.indirection).map(item => {
|
|
1207
1205
|
if (item.String) {
|
|
1208
|
-
return `.${
|
|
1206
|
+
return `.${quotes_1.QuoteUtils.quoteIdentifierAfterDot(item.String.sval || item.String.str)}`;
|
|
1209
1207
|
}
|
|
1210
1208
|
return this.visit(item, context);
|
|
1211
1209
|
});
|
|
@@ -1217,12 +1215,12 @@ class Deparser {
|
|
|
1217
1215
|
}
|
|
1218
1216
|
}
|
|
1219
1217
|
else if (context.insertColumns && node.name) {
|
|
1220
|
-
output.push(
|
|
1218
|
+
output.push(quotes_1.QuoteUtils.quoteIdentifier(node.name));
|
|
1221
1219
|
// Handle indirection for INSERT column lists (e.g., q.c1.r)
|
|
1222
1220
|
if (node.indirection && node.indirection.length > 0) {
|
|
1223
1221
|
const indirectionStrs = list_utils_1.ListUtils.unwrapList(node.indirection).map(item => {
|
|
1224
1222
|
if (item.String) {
|
|
1225
|
-
return `.${
|
|
1223
|
+
return `.${quotes_1.QuoteUtils.quoteIdentifierAfterDot(item.String.sval || item.String.str)}`;
|
|
1226
1224
|
}
|
|
1227
1225
|
return this.visit(item, context);
|
|
1228
1226
|
});
|
|
@@ -1235,7 +1233,7 @@ class Deparser {
|
|
|
1235
1233
|
}
|
|
1236
1234
|
if (node.name) {
|
|
1237
1235
|
output.push('AS');
|
|
1238
|
-
output.push(
|
|
1236
|
+
output.push(quotes_1.QuoteUtils.quoteIdentifier(node.name));
|
|
1239
1237
|
}
|
|
1240
1238
|
}
|
|
1241
1239
|
return output.join(' ');
|
|
@@ -1249,7 +1247,7 @@ class Deparser {
|
|
|
1249
1247
|
if (this.getNodeType(item) === 'ResTarget') {
|
|
1250
1248
|
const resTarget = this.getNodeData(item);
|
|
1251
1249
|
const val = resTarget.val ? this.visit(resTarget.val, context) : '';
|
|
1252
|
-
const alias = resTarget.name ? ` AS ${
|
|
1250
|
+
const alias = resTarget.name ? ` AS ${quotes_1.QuoteUtils.quoteIdentifier(resTarget.name)}` : '';
|
|
1253
1251
|
return val + alias;
|
|
1254
1252
|
}
|
|
1255
1253
|
else {
|
|
@@ -1305,7 +1303,7 @@ class Deparser {
|
|
|
1305
1303
|
const funcname = list_utils_1.ListUtils.unwrapList(node.funcname);
|
|
1306
1304
|
const args = list_utils_1.ListUtils.unwrapList(node.args);
|
|
1307
1305
|
const funcnameParts = funcname.map((n) => n.String?.sval || n.String?.str || '').filter((s) => s);
|
|
1308
|
-
const name =
|
|
1306
|
+
const name = quotes_1.QuoteUtils.quoteDottedName(funcnameParts);
|
|
1309
1307
|
// Handle special SQL syntax functions like XMLEXISTS and EXTRACT
|
|
1310
1308
|
if (node.funcformat === 'COERCE_SQL_SYNTAX' && name === 'pg_catalog.xmlexists' && args.length >= 2) {
|
|
1311
1309
|
const xpath = this.visit(args[0], context);
|
|
@@ -1560,23 +1558,23 @@ class Deparser {
|
|
|
1560
1558
|
else if (nodeAny.sval !== undefined) {
|
|
1561
1559
|
if (typeof nodeAny.sval === 'object' && nodeAny.sval !== null) {
|
|
1562
1560
|
if (nodeAny.sval.sval !== undefined) {
|
|
1563
|
-
return
|
|
1561
|
+
return quotes_1.QuoteUtils.formatEString(nodeAny.sval.sval);
|
|
1564
1562
|
}
|
|
1565
1563
|
else if (nodeAny.sval.String && nodeAny.sval.String.sval !== undefined) {
|
|
1566
|
-
return
|
|
1564
|
+
return quotes_1.QuoteUtils.formatEString(nodeAny.sval.String.sval);
|
|
1567
1565
|
}
|
|
1568
1566
|
else if (Object.keys(nodeAny.sval).length === 0) {
|
|
1569
1567
|
return "''";
|
|
1570
1568
|
}
|
|
1571
1569
|
else {
|
|
1572
|
-
return
|
|
1570
|
+
return quotes_1.QuoteUtils.formatEString(nodeAny.sval.toString());
|
|
1573
1571
|
}
|
|
1574
1572
|
}
|
|
1575
1573
|
else if (nodeAny.sval === null) {
|
|
1576
1574
|
return 'NULL';
|
|
1577
1575
|
}
|
|
1578
1576
|
else {
|
|
1579
|
-
return
|
|
1577
|
+
return quotes_1.QuoteUtils.formatEString(nodeAny.sval);
|
|
1580
1578
|
}
|
|
1581
1579
|
}
|
|
1582
1580
|
else if (nodeAny.boolval !== undefined) {
|
|
@@ -1641,7 +1639,7 @@ class Deparser {
|
|
|
1641
1639
|
return nodeAny.val.Float.fval.toString();
|
|
1642
1640
|
}
|
|
1643
1641
|
else if (nodeAny.val.String?.sval !== undefined) {
|
|
1644
|
-
return
|
|
1642
|
+
return quotes_1.QuoteUtils.escape(nodeAny.val.String.sval);
|
|
1645
1643
|
}
|
|
1646
1644
|
else if (nodeAny.val.Boolean?.boolval !== undefined) {
|
|
1647
1645
|
return nodeAny.val.Boolean.boolval ? 'true' : 'false';
|
|
@@ -1671,9 +1669,9 @@ class Deparser {
|
|
|
1671
1669
|
}
|
|
1672
1670
|
if (nodeAny.String !== undefined) {
|
|
1673
1671
|
if (typeof nodeAny.String === 'object' && nodeAny.String.sval !== undefined) {
|
|
1674
|
-
return
|
|
1672
|
+
return quotes_1.QuoteUtils.escape(nodeAny.String.sval);
|
|
1675
1673
|
}
|
|
1676
|
-
return
|
|
1674
|
+
return quotes_1.QuoteUtils.escape(nodeAny.String);
|
|
1677
1675
|
}
|
|
1678
1676
|
if (Object.keys(nodeAny).length === 0) {
|
|
1679
1677
|
return 'NULL';
|
|
@@ -1687,7 +1685,7 @@ class Deparser {
|
|
|
1687
1685
|
const fields = list_utils_1.ListUtils.unwrapList(node.fields);
|
|
1688
1686
|
return fields.map(field => {
|
|
1689
1687
|
if (field.String) {
|
|
1690
|
-
return
|
|
1688
|
+
return quotes_1.QuoteUtils.quoteIdentifier(field.String.sval || field.String.str);
|
|
1691
1689
|
}
|
|
1692
1690
|
else if (field.A_Star) {
|
|
1693
1691
|
return '*';
|
|
@@ -1764,7 +1762,7 @@ class Deparser {
|
|
|
1764
1762
|
}
|
|
1765
1763
|
return output.join(' ');
|
|
1766
1764
|
}
|
|
1767
|
-
let result = mods(typeName, args);
|
|
1765
|
+
let result = mods(quotes_1.QuoteUtils.quoteIdentifierTypeName(typeName), args);
|
|
1768
1766
|
if (node.arrayBounds && node.arrayBounds.length > 0) {
|
|
1769
1767
|
result += formatArrayBounds(node.arrayBounds);
|
|
1770
1768
|
}
|
|
@@ -1862,7 +1860,7 @@ class Deparser {
|
|
|
1862
1860
|
}
|
|
1863
1861
|
// Use type-name quoting for non-pg_catalog types
|
|
1864
1862
|
// This allows keywords like 'json', 'int', 'boolean' to remain unquoted in type positions
|
|
1865
|
-
let result = mods(
|
|
1863
|
+
let result = mods(quotes_1.QuoteUtils.quoteTypeDottedName(names), args);
|
|
1866
1864
|
if (node.arrayBounds && node.arrayBounds.length > 0) {
|
|
1867
1865
|
result += formatArrayBounds(node.arrayBounds);
|
|
1868
1866
|
}
|
|
@@ -1900,17 +1898,17 @@ class Deparser {
|
|
|
1900
1898
|
}
|
|
1901
1899
|
let tableName = '';
|
|
1902
1900
|
if (node.catalogname) {
|
|
1903
|
-
tableName =
|
|
1901
|
+
tableName = quotes_1.QuoteUtils.quoteIdentifier(node.catalogname);
|
|
1904
1902
|
if (node.schemaname) {
|
|
1905
|
-
tableName += '.' +
|
|
1903
|
+
tableName += '.' + quotes_1.QuoteUtils.quoteIdentifierAfterDot(node.schemaname);
|
|
1906
1904
|
}
|
|
1907
|
-
tableName += '.' +
|
|
1905
|
+
tableName += '.' + quotes_1.QuoteUtils.quoteIdentifierAfterDot(node.relname);
|
|
1908
1906
|
}
|
|
1909
1907
|
else if (node.schemaname) {
|
|
1910
|
-
tableName =
|
|
1908
|
+
tableName = quotes_1.QuoteUtils.quoteQualifiedIdentifier(node.schemaname, node.relname);
|
|
1911
1909
|
}
|
|
1912
1910
|
else {
|
|
1913
|
-
tableName =
|
|
1911
|
+
tableName = quotes_1.QuoteUtils.quoteIdentifier(node.relname);
|
|
1914
1912
|
}
|
|
1915
1913
|
output.push(tableName);
|
|
1916
1914
|
if (node.alias) {
|
|
@@ -2136,7 +2134,7 @@ class Deparser {
|
|
|
2136
2134
|
const indirection = list_utils_1.ListUtils.unwrapList(node.indirection);
|
|
2137
2135
|
for (const subnode of indirection) {
|
|
2138
2136
|
if (subnode.String || subnode.A_Star) {
|
|
2139
|
-
const value = subnode.A_Star ? '*' :
|
|
2137
|
+
const value = subnode.A_Star ? '*' : quotes_1.QuoteUtils.quoteIdentifier(subnode.String.sval || subnode.String.str);
|
|
2140
2138
|
output.push(`.${value}`);
|
|
2141
2139
|
}
|
|
2142
2140
|
else {
|
|
@@ -2282,7 +2280,7 @@ class Deparser {
|
|
|
2282
2280
|
return output.join(' ');
|
|
2283
2281
|
}
|
|
2284
2282
|
quoteIfNeeded(value) {
|
|
2285
|
-
return
|
|
2283
|
+
return quotes_1.QuoteUtils.quoteIdentifier(value);
|
|
2286
2284
|
}
|
|
2287
2285
|
preserveOperatorDefElemCase(defName) {
|
|
2288
2286
|
const caseMap = {
|
|
@@ -2301,7 +2299,7 @@ class Deparser {
|
|
|
2301
2299
|
}
|
|
2302
2300
|
String(node, context) {
|
|
2303
2301
|
if (context.isStringLiteral || context.isEnumValue) {
|
|
2304
|
-
return
|
|
2302
|
+
return quotes_1.QuoteUtils.formatEString(node.sval || '');
|
|
2305
2303
|
}
|
|
2306
2304
|
const value = node.sval || '';
|
|
2307
2305
|
if (context.parentNodeTypes.includes('DefElem') ||
|
|
@@ -2315,7 +2313,7 @@ class Deparser {
|
|
|
2315
2313
|
return value; // Don't quote pure operator symbols like "=" or "-"
|
|
2316
2314
|
}
|
|
2317
2315
|
}
|
|
2318
|
-
return
|
|
2316
|
+
return quotes_1.QuoteUtils.quoteIdentifier(value);
|
|
2319
2317
|
}
|
|
2320
2318
|
Integer(node, context) {
|
|
2321
2319
|
return node.ival?.toString() || '0';
|
|
@@ -2492,7 +2490,7 @@ class Deparser {
|
|
|
2492
2490
|
ColumnDef(node, context) {
|
|
2493
2491
|
const output = [];
|
|
2494
2492
|
if (node.colname) {
|
|
2495
|
-
output.push(
|
|
2493
|
+
output.push(quotes_1.QuoteUtils.quoteIdentifier(node.colname));
|
|
2496
2494
|
}
|
|
2497
2495
|
if (node.typeName) {
|
|
2498
2496
|
output.push(this.TypeName(node.typeName, context));
|
|
@@ -2533,7 +2531,7 @@ class Deparser {
|
|
|
2533
2531
|
// Handle constraint name if present
|
|
2534
2532
|
if (node.conname && (node.contype === 'CONSTR_CHECK' || node.contype === 'CONSTR_UNIQUE' || node.contype === 'CONSTR_PRIMARY' || node.contype === 'CONSTR_FOREIGN')) {
|
|
2535
2533
|
output.push('CONSTRAINT');
|
|
2536
|
-
output.push(
|
|
2534
|
+
output.push(quotes_1.QuoteUtils.quoteIdentifier(node.conname));
|
|
2537
2535
|
}
|
|
2538
2536
|
switch (node.contype) {
|
|
2539
2537
|
case 'CONSTR_NULL':
|
|
@@ -2876,6 +2874,10 @@ class Deparser {
|
|
|
2876
2874
|
});
|
|
2877
2875
|
output.push(`(${exclusionElements.join(', ')})`);
|
|
2878
2876
|
}
|
|
2877
|
+
if (node.where_clause) {
|
|
2878
|
+
output.push('WHERE');
|
|
2879
|
+
output.push(context.parens(this.visit(node.where_clause, context)));
|
|
2880
|
+
}
|
|
2879
2881
|
break;
|
|
2880
2882
|
}
|
|
2881
2883
|
// Handle deferrable constraints for all constraint types that support it
|
|
@@ -3009,6 +3011,8 @@ class Deparser {
|
|
|
3009
3011
|
if (!node.frameOptions)
|
|
3010
3012
|
return null;
|
|
3011
3013
|
const frameOptions = node.frameOptions;
|
|
3014
|
+
const EXCLUDE_MASK = 0x8000 | 0x10000 | 0x20000;
|
|
3015
|
+
const baseFrameOptions = frameOptions & ~EXCLUDE_MASK;
|
|
3012
3016
|
const frameParts = [];
|
|
3013
3017
|
if (frameOptions & 0x01) { // FRAMEOPTION_NONDEFAULT
|
|
3014
3018
|
if (frameOptions & 0x02) { // FRAMEOPTION_RANGE
|
|
@@ -3025,31 +3029,31 @@ class Deparser {
|
|
|
3025
3029
|
return null;
|
|
3026
3030
|
const boundsParts = [];
|
|
3027
3031
|
// Handle specific frameOptions values that have known mappings
|
|
3028
|
-
if (
|
|
3032
|
+
if (baseFrameOptions === 789) {
|
|
3029
3033
|
boundsParts.push('CURRENT ROW');
|
|
3030
3034
|
boundsParts.push('AND UNBOUNDED FOLLOWING');
|
|
3031
3035
|
}
|
|
3032
|
-
else if (
|
|
3036
|
+
else if (baseFrameOptions === 1077) {
|
|
3033
3037
|
boundsParts.push('UNBOUNDED PRECEDING');
|
|
3034
3038
|
boundsParts.push('AND CURRENT ROW');
|
|
3035
3039
|
}
|
|
3036
|
-
else if (
|
|
3040
|
+
else if (baseFrameOptions === 18453) {
|
|
3037
3041
|
if (node.startOffset && node.endOffset) {
|
|
3038
3042
|
boundsParts.push(`${this.visit(node.startOffset, context)} PRECEDING`);
|
|
3039
3043
|
boundsParts.push(`AND ${this.visit(node.endOffset, context)} FOLLOWING`);
|
|
3040
3044
|
}
|
|
3041
3045
|
}
|
|
3042
|
-
else if (
|
|
3046
|
+
else if (baseFrameOptions === 1557) {
|
|
3043
3047
|
boundsParts.push('CURRENT ROW');
|
|
3044
3048
|
boundsParts.push('AND CURRENT ROW');
|
|
3045
3049
|
}
|
|
3046
|
-
else if (
|
|
3050
|
+
else if (baseFrameOptions === 16917) {
|
|
3047
3051
|
boundsParts.push('CURRENT ROW');
|
|
3048
3052
|
if (node.endOffset) {
|
|
3049
3053
|
boundsParts.push(`AND ${this.visit(node.endOffset, context)} FOLLOWING`);
|
|
3050
3054
|
}
|
|
3051
3055
|
}
|
|
3052
|
-
else if (
|
|
3056
|
+
else if (baseFrameOptions === 1058) {
|
|
3053
3057
|
return null;
|
|
3054
3058
|
}
|
|
3055
3059
|
else {
|
|
@@ -3103,6 +3107,16 @@ class Deparser {
|
|
|
3103
3107
|
frameParts.push('BETWEEN');
|
|
3104
3108
|
frameParts.push(boundsParts.join(' '));
|
|
3105
3109
|
}
|
|
3110
|
+
// EXCLUDE clause
|
|
3111
|
+
if (frameOptions & 0x8000) { // FRAMEOPTION_EXCLUDE_CURRENT_ROW
|
|
3112
|
+
frameParts.push('EXCLUDE CURRENT ROW');
|
|
3113
|
+
}
|
|
3114
|
+
else if (frameOptions & 0x10000) { // FRAMEOPTION_EXCLUDE_GROUP
|
|
3115
|
+
frameParts.push('EXCLUDE GROUP');
|
|
3116
|
+
}
|
|
3117
|
+
else if (frameOptions & 0x20000) { // FRAMEOPTION_EXCLUDE_TIES
|
|
3118
|
+
frameParts.push('EXCLUDE TIES');
|
|
3119
|
+
}
|
|
3106
3120
|
return frameParts.join(' ');
|
|
3107
3121
|
}
|
|
3108
3122
|
SortBy(node, context) {
|
|
@@ -3430,7 +3444,7 @@ class Deparser {
|
|
|
3430
3444
|
output.push('IF NOT EXISTS');
|
|
3431
3445
|
}
|
|
3432
3446
|
if (node.idxname) {
|
|
3433
|
-
output.push(
|
|
3447
|
+
output.push(quotes_1.QuoteUtils.quoteIdentifier(node.idxname));
|
|
3434
3448
|
}
|
|
3435
3449
|
output.push('ON');
|
|
3436
3450
|
if (node.relation) {
|
|
@@ -3464,14 +3478,14 @@ class Deparser {
|
|
|
3464
3478
|
}
|
|
3465
3479
|
if (node.tableSpace) {
|
|
3466
3480
|
output.push('TABLESPACE');
|
|
3467
|
-
output.push(
|
|
3481
|
+
output.push(quotes_1.QuoteUtils.quoteIdentifier(node.tableSpace));
|
|
3468
3482
|
}
|
|
3469
3483
|
return output.join(' ');
|
|
3470
3484
|
}
|
|
3471
3485
|
IndexElem(node, context) {
|
|
3472
3486
|
const output = [];
|
|
3473
3487
|
if (node.name) {
|
|
3474
|
-
output.push(
|
|
3488
|
+
output.push(quotes_1.QuoteUtils.quoteIdentifier(node.name));
|
|
3475
3489
|
}
|
|
3476
3490
|
else if (node.expr) {
|
|
3477
3491
|
output.push(context.parens(this.visit(node.expr, context)));
|
|
@@ -3522,7 +3536,7 @@ class Deparser {
|
|
|
3522
3536
|
PartitionElem(node, context) {
|
|
3523
3537
|
const output = [];
|
|
3524
3538
|
if (node.name) {
|
|
3525
|
-
output.push(
|
|
3539
|
+
output.push(quotes_1.QuoteUtils.quoteIdentifier(node.name));
|
|
3526
3540
|
}
|
|
3527
3541
|
else if (node.expr) {
|
|
3528
3542
|
output.push(context.parens(this.visit(node.expr, context)));
|
|
@@ -3772,19 +3786,19 @@ class Deparser {
|
|
|
3772
3786
|
case 'TRANS_STMT_SAVEPOINT':
|
|
3773
3787
|
output.push('SAVEPOINT');
|
|
3774
3788
|
if (node.savepoint_name) {
|
|
3775
|
-
output.push(
|
|
3789
|
+
output.push(quotes_1.QuoteUtils.quoteIdentifier(node.savepoint_name));
|
|
3776
3790
|
}
|
|
3777
3791
|
break;
|
|
3778
3792
|
case 'TRANS_STMT_RELEASE':
|
|
3779
3793
|
output.push('RELEASE SAVEPOINT');
|
|
3780
3794
|
if (node.savepoint_name) {
|
|
3781
|
-
output.push(
|
|
3795
|
+
output.push(quotes_1.QuoteUtils.quoteIdentifier(node.savepoint_name));
|
|
3782
3796
|
}
|
|
3783
3797
|
break;
|
|
3784
3798
|
case 'TRANS_STMT_ROLLBACK_TO':
|
|
3785
3799
|
output.push('ROLLBACK TO');
|
|
3786
3800
|
if (node.savepoint_name) {
|
|
3787
|
-
output.push(
|
|
3801
|
+
output.push(quotes_1.QuoteUtils.quoteIdentifier(node.savepoint_name));
|
|
3788
3802
|
}
|
|
3789
3803
|
break;
|
|
3790
3804
|
case 'TRANS_STMT_PREPARE':
|
|
@@ -3881,16 +3895,16 @@ class Deparser {
|
|
|
3881
3895
|
return this.visit(arg, context);
|
|
3882
3896
|
}).join(', ') : '';
|
|
3883
3897
|
// Handle args - always include TO clause if args exist (even if empty string)
|
|
3884
|
-
const paramName =
|
|
3898
|
+
const paramName = quotes_1.QuoteUtils.quoteIdentifier(node.name);
|
|
3885
3899
|
if (!node.args || node.args.length === 0) {
|
|
3886
3900
|
return `SET ${localPrefix}${paramName}`;
|
|
3887
3901
|
}
|
|
3888
3902
|
return `SET ${localPrefix}${paramName} TO ${args}`;
|
|
3889
3903
|
case 'VAR_SET_DEFAULT':
|
|
3890
|
-
const defaultParamName =
|
|
3904
|
+
const defaultParamName = quotes_1.QuoteUtils.quoteIdentifier(node.name);
|
|
3891
3905
|
return `SET ${defaultParamName} TO DEFAULT`;
|
|
3892
3906
|
case 'VAR_SET_CURRENT':
|
|
3893
|
-
const currentParamName =
|
|
3907
|
+
const currentParamName = quotes_1.QuoteUtils.quoteIdentifier(node.name);
|
|
3894
3908
|
return `SET ${currentParamName} FROM CURRENT`;
|
|
3895
3909
|
case 'VAR_SET_MULTI':
|
|
3896
3910
|
if (node.name === 'TRANSACTION' || node.name === 'SESSION CHARACTERISTICS') {
|
|
@@ -3964,7 +3978,7 @@ class Deparser {
|
|
|
3964
3978
|
return `SET ${assignments}`;
|
|
3965
3979
|
}
|
|
3966
3980
|
case 'VAR_RESET':
|
|
3967
|
-
const resetParamName =
|
|
3981
|
+
const resetParamName = quotes_1.QuoteUtils.quoteIdentifier(node.name);
|
|
3968
3982
|
return `RESET ${resetParamName}`;
|
|
3969
3983
|
case 'VAR_RESET_ALL':
|
|
3970
3984
|
return 'RESET ALL';
|
|
@@ -3984,7 +3998,7 @@ class Deparser {
|
|
|
3984
3998
|
output.push('IF NOT EXISTS');
|
|
3985
3999
|
}
|
|
3986
4000
|
if (node.schemaname) {
|
|
3987
|
-
output.push(
|
|
4001
|
+
output.push(quotes_1.QuoteUtils.quoteIdentifier(node.schemaname));
|
|
3988
4002
|
}
|
|
3989
4003
|
if (node.authrole) {
|
|
3990
4004
|
output.push('AUTHORIZATION');
|
|
@@ -4233,7 +4247,7 @@ class Deparser {
|
|
|
4233
4247
|
if (objList && objList.List && objList.List.items) {
|
|
4234
4248
|
const items = objList.List.items.map((item) => {
|
|
4235
4249
|
if (item.String && item.String.sval) {
|
|
4236
|
-
return
|
|
4250
|
+
return quotes_1.QuoteUtils.quoteIdentifier(item.String.sval);
|
|
4237
4251
|
}
|
|
4238
4252
|
return this.visit(item, context);
|
|
4239
4253
|
}).filter((name) => name && name.trim());
|
|
@@ -4267,13 +4281,13 @@ class Deparser {
|
|
|
4267
4281
|
if (items.length === 2) {
|
|
4268
4282
|
const accessMethod = items[0];
|
|
4269
4283
|
const objectName = items[1];
|
|
4270
|
-
return `${
|
|
4284
|
+
return `${quotes_1.QuoteUtils.quoteIdentifier(objectName)} USING ${accessMethod}`;
|
|
4271
4285
|
}
|
|
4272
4286
|
else if (items.length === 3) {
|
|
4273
4287
|
const accessMethod = items[0];
|
|
4274
4288
|
const schemaName = items[1];
|
|
4275
4289
|
const objectName = items[2];
|
|
4276
|
-
return `${
|
|
4290
|
+
return `${quotes_1.QuoteUtils.quoteQualifiedIdentifier(schemaName, objectName)} USING ${accessMethod}`;
|
|
4277
4291
|
}
|
|
4278
4292
|
return items.join('.');
|
|
4279
4293
|
}
|
|
@@ -4316,7 +4330,7 @@ class Deparser {
|
|
|
4316
4330
|
if (objList && objList.List && objList.List.items) {
|
|
4317
4331
|
const items = objList.List.items.map((item) => {
|
|
4318
4332
|
if (item.String && item.String.sval) {
|
|
4319
|
-
return
|
|
4333
|
+
return quotes_1.QuoteUtils.quoteIdentifier(item.String.sval);
|
|
4320
4334
|
}
|
|
4321
4335
|
return this.visit(item, context);
|
|
4322
4336
|
}).filter((name) => name && name.trim());
|
|
@@ -4364,7 +4378,7 @@ class Deparser {
|
|
|
4364
4378
|
PLAssignStmt(node, context) {
|
|
4365
4379
|
const output = [];
|
|
4366
4380
|
if (node.name) {
|
|
4367
|
-
let nameWithIndirection =
|
|
4381
|
+
let nameWithIndirection = quotes_1.QuoteUtils.quoteIdentifier(node.name);
|
|
4368
4382
|
if (node.indirection && node.indirection.length > 0) {
|
|
4369
4383
|
const indirectionStr = node.indirection
|
|
4370
4384
|
.map((ind) => this.visit(ind, context))
|
|
@@ -4513,7 +4527,7 @@ class Deparser {
|
|
|
4513
4527
|
const parts = [];
|
|
4514
4528
|
const indentedParts = [];
|
|
4515
4529
|
if (colDefData.colname) {
|
|
4516
|
-
parts.push(
|
|
4530
|
+
parts.push(quotes_1.QuoteUtils.quoteIdentifier(colDefData.colname));
|
|
4517
4531
|
}
|
|
4518
4532
|
if (colDefData.typeName) {
|
|
4519
4533
|
parts.push(this.TypeName(colDefData.typeName, context));
|
|
@@ -4571,7 +4585,7 @@ class Deparser {
|
|
|
4571
4585
|
else {
|
|
4572
4586
|
const parts = [];
|
|
4573
4587
|
if (colDefData.colname) {
|
|
4574
|
-
parts.push(
|
|
4588
|
+
parts.push(quotes_1.QuoteUtils.quoteIdentifier(colDefData.colname));
|
|
4575
4589
|
}
|
|
4576
4590
|
if (colDefData.typeName) {
|
|
4577
4591
|
parts.push(this.TypeName(colDefData.typeName, context));
|
|
@@ -4625,7 +4639,7 @@ class Deparser {
|
|
|
4625
4639
|
}
|
|
4626
4640
|
}
|
|
4627
4641
|
if (node.name) {
|
|
4628
|
-
output.push(
|
|
4642
|
+
output.push(quotes_1.QuoteUtils.quoteIdentifier(node.name));
|
|
4629
4643
|
}
|
|
4630
4644
|
if (node.behavior === 'DROP_CASCADE') {
|
|
4631
4645
|
output.push('CASCADE');
|
|
@@ -4642,7 +4656,7 @@ class Deparser {
|
|
|
4642
4656
|
output.push('ALTER COLUMN');
|
|
4643
4657
|
}
|
|
4644
4658
|
if (node.name) {
|
|
4645
|
-
output.push(
|
|
4659
|
+
output.push(quotes_1.QuoteUtils.quoteIdentifier(node.name));
|
|
4646
4660
|
}
|
|
4647
4661
|
output.push('TYPE');
|
|
4648
4662
|
if (node.def) {
|
|
@@ -4669,7 +4683,7 @@ class Deparser {
|
|
|
4669
4683
|
case 'AT_SetTableSpace':
|
|
4670
4684
|
output.push('SET TABLESPACE');
|
|
4671
4685
|
if (node.name) {
|
|
4672
|
-
output.push(
|
|
4686
|
+
output.push(quotes_1.QuoteUtils.quoteIdentifier(node.name));
|
|
4673
4687
|
}
|
|
4674
4688
|
break;
|
|
4675
4689
|
case 'AT_AddConstraint':
|
|
@@ -4687,7 +4701,7 @@ class Deparser {
|
|
|
4687
4701
|
output.push('DROP CONSTRAINT');
|
|
4688
4702
|
}
|
|
4689
4703
|
if (node.name) {
|
|
4690
|
-
output.push(
|
|
4704
|
+
output.push(quotes_1.QuoteUtils.quoteIdentifier(node.name));
|
|
4691
4705
|
}
|
|
4692
4706
|
if (node.behavior === 'DROP_CASCADE') {
|
|
4693
4707
|
output.push('CASCADE');
|
|
@@ -4725,7 +4739,7 @@ class Deparser {
|
|
|
4725
4739
|
case 'AT_ColumnDefault':
|
|
4726
4740
|
output.push('ALTER COLUMN');
|
|
4727
4741
|
if (node.name) {
|
|
4728
|
-
output.push(
|
|
4742
|
+
output.push(quotes_1.QuoteUtils.quoteIdentifier(node.name));
|
|
4729
4743
|
}
|
|
4730
4744
|
if (node.def) {
|
|
4731
4745
|
output.push('SET DEFAULT');
|
|
@@ -4738,7 +4752,7 @@ class Deparser {
|
|
|
4738
4752
|
case 'AT_SetStorage':
|
|
4739
4753
|
output.push('ALTER COLUMN');
|
|
4740
4754
|
if (node.name) {
|
|
4741
|
-
output.push(
|
|
4755
|
+
output.push(quotes_1.QuoteUtils.quoteIdentifier(node.name));
|
|
4742
4756
|
}
|
|
4743
4757
|
output.push('SET STORAGE');
|
|
4744
4758
|
if (node.def) {
|
|
@@ -4749,7 +4763,7 @@ class Deparser {
|
|
|
4749
4763
|
case 'AT_ClusterOn':
|
|
4750
4764
|
output.push('CLUSTER ON');
|
|
4751
4765
|
if (node.name) {
|
|
4752
|
-
output.push(
|
|
4766
|
+
output.push(quotes_1.QuoteUtils.quoteIdentifier(node.name));
|
|
4753
4767
|
}
|
|
4754
4768
|
break;
|
|
4755
4769
|
case 'AT_DropCluster':
|
|
@@ -4776,21 +4790,21 @@ class Deparser {
|
|
|
4776
4790
|
case 'AT_SetNotNull':
|
|
4777
4791
|
output.push('ALTER COLUMN');
|
|
4778
4792
|
if (node.name) {
|
|
4779
|
-
output.push(
|
|
4793
|
+
output.push(quotes_1.QuoteUtils.quoteIdentifier(node.name));
|
|
4780
4794
|
}
|
|
4781
4795
|
output.push('SET NOT NULL');
|
|
4782
4796
|
break;
|
|
4783
4797
|
case 'AT_DropNotNull':
|
|
4784
4798
|
output.push('ALTER COLUMN');
|
|
4785
4799
|
if (node.name) {
|
|
4786
|
-
output.push(
|
|
4800
|
+
output.push(quotes_1.QuoteUtils.quoteIdentifier(node.name));
|
|
4787
4801
|
}
|
|
4788
4802
|
output.push('DROP NOT NULL');
|
|
4789
4803
|
break;
|
|
4790
4804
|
case 'AT_SetStatistics':
|
|
4791
4805
|
output.push('ALTER COLUMN');
|
|
4792
4806
|
if (node.name) {
|
|
4793
|
-
output.push(
|
|
4807
|
+
output.push(quotes_1.QuoteUtils.quoteIdentifier(node.name));
|
|
4794
4808
|
}
|
|
4795
4809
|
else if (node.num !== undefined && node.num !== null) {
|
|
4796
4810
|
output.push(node.num.toString());
|
|
@@ -4803,7 +4817,7 @@ class Deparser {
|
|
|
4803
4817
|
case 'AT_SetOptions':
|
|
4804
4818
|
output.push('ALTER COLUMN');
|
|
4805
4819
|
if (node.name) {
|
|
4806
|
-
output.push(
|
|
4820
|
+
output.push(quotes_1.QuoteUtils.quoteIdentifier(node.name));
|
|
4807
4821
|
}
|
|
4808
4822
|
output.push('SET');
|
|
4809
4823
|
if (node.def) {
|
|
@@ -4820,7 +4834,7 @@ class Deparser {
|
|
|
4820
4834
|
case 'AT_ResetOptions':
|
|
4821
4835
|
output.push('ALTER COLUMN');
|
|
4822
4836
|
if (node.name) {
|
|
4823
|
-
output.push(
|
|
4837
|
+
output.push(quotes_1.QuoteUtils.quoteIdentifier(node.name));
|
|
4824
4838
|
}
|
|
4825
4839
|
output.push('RESET');
|
|
4826
4840
|
if (node.def) {
|
|
@@ -4837,7 +4851,7 @@ class Deparser {
|
|
|
4837
4851
|
case 'AT_SetCompression':
|
|
4838
4852
|
output.push('ALTER COLUMN');
|
|
4839
4853
|
if (node.name) {
|
|
4840
|
-
output.push(
|
|
4854
|
+
output.push(quotes_1.QuoteUtils.quoteIdentifier(node.name));
|
|
4841
4855
|
}
|
|
4842
4856
|
output.push('SET COMPRESSION');
|
|
4843
4857
|
if (node.def) {
|
|
@@ -4847,31 +4861,31 @@ class Deparser {
|
|
|
4847
4861
|
case 'AT_ValidateConstraint':
|
|
4848
4862
|
output.push('VALIDATE CONSTRAINT');
|
|
4849
4863
|
if (node.name) {
|
|
4850
|
-
output.push(
|
|
4864
|
+
output.push(quotes_1.QuoteUtils.quoteIdentifier(node.name));
|
|
4851
4865
|
}
|
|
4852
4866
|
break;
|
|
4853
4867
|
case 'AT_EnableTrig':
|
|
4854
4868
|
output.push('ENABLE TRIGGER');
|
|
4855
4869
|
if (node.name) {
|
|
4856
|
-
output.push(
|
|
4870
|
+
output.push(quotes_1.QuoteUtils.quoteIdentifier(node.name));
|
|
4857
4871
|
}
|
|
4858
4872
|
break;
|
|
4859
4873
|
case 'AT_EnableAlwaysTrig':
|
|
4860
4874
|
output.push('ENABLE ALWAYS TRIGGER');
|
|
4861
4875
|
if (node.name) {
|
|
4862
|
-
output.push(
|
|
4876
|
+
output.push(quotes_1.QuoteUtils.quoteIdentifier(node.name));
|
|
4863
4877
|
}
|
|
4864
4878
|
break;
|
|
4865
4879
|
case 'AT_EnableReplicaTrig':
|
|
4866
4880
|
output.push('ENABLE REPLICA TRIGGER');
|
|
4867
4881
|
if (node.name) {
|
|
4868
|
-
output.push(
|
|
4882
|
+
output.push(quotes_1.QuoteUtils.quoteIdentifier(node.name));
|
|
4869
4883
|
}
|
|
4870
4884
|
break;
|
|
4871
4885
|
case 'AT_DisableTrig':
|
|
4872
4886
|
output.push('DISABLE TRIGGER');
|
|
4873
4887
|
if (node.name) {
|
|
4874
|
-
output.push(
|
|
4888
|
+
output.push(quotes_1.QuoteUtils.quoteIdentifier(node.name));
|
|
4875
4889
|
}
|
|
4876
4890
|
break;
|
|
4877
4891
|
case 'AT_EnableTrigAll':
|
|
@@ -4889,31 +4903,31 @@ class Deparser {
|
|
|
4889
4903
|
case 'AT_EnableRule':
|
|
4890
4904
|
output.push('ENABLE RULE');
|
|
4891
4905
|
if (node.name) {
|
|
4892
|
-
output.push(
|
|
4906
|
+
output.push(quotes_1.QuoteUtils.quoteIdentifier(node.name));
|
|
4893
4907
|
}
|
|
4894
4908
|
break;
|
|
4895
4909
|
case 'AT_EnableAlwaysRule':
|
|
4896
4910
|
output.push('ENABLE ALWAYS RULE');
|
|
4897
4911
|
if (node.name) {
|
|
4898
|
-
output.push(
|
|
4912
|
+
output.push(quotes_1.QuoteUtils.quoteIdentifier(node.name));
|
|
4899
4913
|
}
|
|
4900
4914
|
break;
|
|
4901
4915
|
case 'AT_EnableReplicaRule':
|
|
4902
4916
|
output.push('ENABLE REPLICA RULE');
|
|
4903
4917
|
if (node.name) {
|
|
4904
|
-
output.push(
|
|
4918
|
+
output.push(quotes_1.QuoteUtils.quoteIdentifier(node.name));
|
|
4905
4919
|
}
|
|
4906
4920
|
break;
|
|
4907
4921
|
case 'AT_DisableRule':
|
|
4908
4922
|
output.push('DISABLE RULE');
|
|
4909
4923
|
if (node.name) {
|
|
4910
|
-
output.push(
|
|
4924
|
+
output.push(quotes_1.QuoteUtils.quoteIdentifier(node.name));
|
|
4911
4925
|
}
|
|
4912
4926
|
break;
|
|
4913
4927
|
case 'AT_SetAccessMethod':
|
|
4914
4928
|
output.push('SET ACCESS METHOD');
|
|
4915
4929
|
if (node.name) {
|
|
4916
|
-
output.push(
|
|
4930
|
+
output.push(quotes_1.QuoteUtils.quoteIdentifier(node.name));
|
|
4917
4931
|
}
|
|
4918
4932
|
else {
|
|
4919
4933
|
// Handle DEFAULT access method case
|
|
@@ -4967,7 +4981,7 @@ class Deparser {
|
|
|
4967
4981
|
case 'AT_CookedColumnDefault':
|
|
4968
4982
|
output.push('ALTER COLUMN');
|
|
4969
4983
|
if (node.name) {
|
|
4970
|
-
output.push(
|
|
4984
|
+
output.push(quotes_1.QuoteUtils.quoteIdentifier(node.name));
|
|
4971
4985
|
}
|
|
4972
4986
|
if (node.def) {
|
|
4973
4987
|
output.push('SET DEFAULT');
|
|
@@ -4980,7 +4994,7 @@ class Deparser {
|
|
|
4980
4994
|
case 'AT_SetExpression':
|
|
4981
4995
|
output.push('ALTER COLUMN');
|
|
4982
4996
|
if (node.name) {
|
|
4983
|
-
output.push(
|
|
4997
|
+
output.push(quotes_1.QuoteUtils.quoteIdentifier(node.name));
|
|
4984
4998
|
}
|
|
4985
4999
|
output.push('SET EXPRESSION');
|
|
4986
5000
|
if (node.def) {
|
|
@@ -4990,14 +5004,14 @@ class Deparser {
|
|
|
4990
5004
|
case 'AT_DropExpression':
|
|
4991
5005
|
output.push('ALTER COLUMN');
|
|
4992
5006
|
if (node.name) {
|
|
4993
|
-
output.push(
|
|
5007
|
+
output.push(quotes_1.QuoteUtils.quoteIdentifier(node.name));
|
|
4994
5008
|
}
|
|
4995
5009
|
output.push('DROP EXPRESSION');
|
|
4996
5010
|
break;
|
|
4997
5011
|
case 'AT_CheckNotNull':
|
|
4998
5012
|
output.push('ALTER COLUMN');
|
|
4999
5013
|
if (node.name) {
|
|
5000
|
-
output.push(
|
|
5014
|
+
output.push(quotes_1.QuoteUtils.quoteIdentifier(node.name));
|
|
5001
5015
|
}
|
|
5002
5016
|
output.push('SET NOT NULL');
|
|
5003
5017
|
break;
|
|
@@ -5030,7 +5044,7 @@ class Deparser {
|
|
|
5030
5044
|
if (node.def && this.getNodeType(node.def) === 'Constraint') {
|
|
5031
5045
|
const constraintData = this.getNodeData(node.def);
|
|
5032
5046
|
if (constraintData.conname) {
|
|
5033
|
-
output.push(
|
|
5047
|
+
output.push(quotes_1.QuoteUtils.quoteIdentifier(constraintData.conname));
|
|
5034
5048
|
if (constraintData.deferrable !== undefined) {
|
|
5035
5049
|
output.push(constraintData.deferrable ? 'DEFERRABLE' : 'NOT DEFERRABLE');
|
|
5036
5050
|
}
|
|
@@ -5040,7 +5054,7 @@ class Deparser {
|
|
|
5040
5054
|
}
|
|
5041
5055
|
}
|
|
5042
5056
|
else if (node.name) {
|
|
5043
|
-
output.push(
|
|
5057
|
+
output.push(quotes_1.QuoteUtils.quoteIdentifier(node.name));
|
|
5044
5058
|
if (node.def) {
|
|
5045
5059
|
output.push(this.visit(node.def, context));
|
|
5046
5060
|
}
|
|
@@ -5061,7 +5075,7 @@ class Deparser {
|
|
|
5061
5075
|
case 'AT_AlterColumnGenericOptions':
|
|
5062
5076
|
output.push('ALTER COLUMN');
|
|
5063
5077
|
if (node.name) {
|
|
5064
|
-
output.push(
|
|
5078
|
+
output.push(quotes_1.QuoteUtils.quoteIdentifier(node.name));
|
|
5065
5079
|
}
|
|
5066
5080
|
output.push('OPTIONS');
|
|
5067
5081
|
if (node.def) {
|
|
@@ -5115,7 +5129,7 @@ class Deparser {
|
|
|
5115
5129
|
case 'AT_AddIdentity':
|
|
5116
5130
|
output.push('ALTER COLUMN');
|
|
5117
5131
|
if (node.name) {
|
|
5118
|
-
output.push(
|
|
5132
|
+
output.push(quotes_1.QuoteUtils.quoteIdentifier(node.name));
|
|
5119
5133
|
}
|
|
5120
5134
|
output.push('ADD');
|
|
5121
5135
|
if (node.def) {
|
|
@@ -5125,7 +5139,7 @@ class Deparser {
|
|
|
5125
5139
|
case 'AT_SetIdentity':
|
|
5126
5140
|
output.push('ALTER COLUMN');
|
|
5127
5141
|
if (node.name) {
|
|
5128
|
-
output.push(
|
|
5142
|
+
output.push(quotes_1.QuoteUtils.quoteIdentifier(node.name));
|
|
5129
5143
|
}
|
|
5130
5144
|
output.push('SET');
|
|
5131
5145
|
if (node.def) {
|
|
@@ -5135,7 +5149,7 @@ class Deparser {
|
|
|
5135
5149
|
case 'AT_DropIdentity':
|
|
5136
5150
|
output.push('ALTER COLUMN');
|
|
5137
5151
|
if (node.name) {
|
|
5138
|
-
output.push(
|
|
5152
|
+
output.push(quotes_1.QuoteUtils.quoteIdentifier(node.name));
|
|
5139
5153
|
}
|
|
5140
5154
|
output.push('DROP IDENTITY');
|
|
5141
5155
|
if (node.behavior === 'DROP_CASCADE') {
|
|
@@ -5170,7 +5184,7 @@ class Deparser {
|
|
|
5170
5184
|
}
|
|
5171
5185
|
if (node.funcname && node.funcname.length > 0) {
|
|
5172
5186
|
const funcnameParts = node.funcname.map((name) => name.String?.sval || name.String?.str || '').filter((s) => s);
|
|
5173
|
-
const funcName =
|
|
5187
|
+
const funcName = quotes_1.QuoteUtils.quoteDottedName(funcnameParts);
|
|
5174
5188
|
if (node.parameters && node.parameters.length > 0) {
|
|
5175
5189
|
const params = node.parameters
|
|
5176
5190
|
.filter((param) => {
|
|
@@ -5287,7 +5301,7 @@ class Deparser {
|
|
|
5287
5301
|
}
|
|
5288
5302
|
}
|
|
5289
5303
|
if (node.name) {
|
|
5290
|
-
output.push(
|
|
5304
|
+
output.push(quotes_1.QuoteUtils.quoteIdentifier(node.name));
|
|
5291
5305
|
}
|
|
5292
5306
|
if (node.argType) {
|
|
5293
5307
|
output.push(this.TypeName(node.argType, context));
|
|
@@ -5359,7 +5373,7 @@ class Deparser {
|
|
|
5359
5373
|
output.push('ROLE');
|
|
5360
5374
|
}
|
|
5361
5375
|
if (node.role) {
|
|
5362
|
-
const roleName =
|
|
5376
|
+
const roleName = quotes_1.QuoteUtils.quoteIdentifier(node.role);
|
|
5363
5377
|
output.push(roleName);
|
|
5364
5378
|
}
|
|
5365
5379
|
if (node.options) {
|
|
@@ -5401,7 +5415,7 @@ class Deparser {
|
|
|
5401
5415
|
if (context.parentNodeTypes.includes('DefineStmt') &&
|
|
5402
5416
|
['hashes', 'merges'].includes(node.defname.toLowerCase()) && !node.arg) {
|
|
5403
5417
|
if (node.defname !== node.defname.toLowerCase() && node.defname !== node.defname.toUpperCase()) {
|
|
5404
|
-
return
|
|
5418
|
+
return quotes_1.QuoteUtils.quoteIdentifier(node.defname);
|
|
5405
5419
|
}
|
|
5406
5420
|
return node.defname.charAt(0).toUpperCase() + node.defname.slice(1).toLowerCase();
|
|
5407
5421
|
}
|
|
@@ -5423,7 +5437,7 @@ class Deparser {
|
|
|
5423
5437
|
const finalValue = typeof argValue === 'string' && !argValue.startsWith("'")
|
|
5424
5438
|
? `'${argValue}'`
|
|
5425
5439
|
: argValue;
|
|
5426
|
-
const quotedDefname =
|
|
5440
|
+
const quotedDefname = quotes_1.QuoteUtils.quoteIdentifier(node.defname);
|
|
5427
5441
|
if (node.defaction === 'DEFELEM_ADD') {
|
|
5428
5442
|
return `ADD ${quotedDefname} ${finalValue}`;
|
|
5429
5443
|
}
|
|
@@ -5447,7 +5461,7 @@ class Deparser {
|
|
|
5447
5461
|
else if (node.defaction === 'DEFELEM_SET') {
|
|
5448
5462
|
return `SET ${node.defname} ${quotedValue}`;
|
|
5449
5463
|
}
|
|
5450
|
-
const quotedDefname =
|
|
5464
|
+
const quotedDefname = quotes_1.QuoteUtils.quoteIdentifier(node.defname);
|
|
5451
5465
|
return `${quotedDefname} ${quotedValue}`;
|
|
5452
5466
|
}
|
|
5453
5467
|
else if (node.defaction === 'DEFELEM_DROP') {
|
|
@@ -5498,16 +5512,16 @@ class Deparser {
|
|
|
5498
5512
|
}
|
|
5499
5513
|
if (context.parentNodeTypes.includes('CreatedbStmt') || context.parentNodeTypes.includes('DropdbStmt')) {
|
|
5500
5514
|
const quotedValue = typeof argValue === 'string'
|
|
5501
|
-
?
|
|
5515
|
+
? quotes_1.QuoteUtils.escape(argValue)
|
|
5502
5516
|
: argValue;
|
|
5503
5517
|
return `${node.defname} = ${quotedValue}`;
|
|
5504
5518
|
}
|
|
5505
5519
|
// CreateForeignServerStmt and AlterForeignServerStmt use space format like CreateFdwStmt
|
|
5506
5520
|
if (context.parentNodeTypes.includes('CreateForeignServerStmt') || context.parentNodeTypes.includes('AlterForeignServerStmt')) {
|
|
5507
5521
|
const quotedValue = typeof argValue === 'string'
|
|
5508
|
-
?
|
|
5522
|
+
? quotes_1.QuoteUtils.escape(argValue)
|
|
5509
5523
|
: argValue;
|
|
5510
|
-
const quotedDefname =
|
|
5524
|
+
const quotedDefname = quotes_1.QuoteUtils.quoteIdentifier(node.defname);
|
|
5511
5525
|
return `${quotedDefname} ${quotedValue}`;
|
|
5512
5526
|
}
|
|
5513
5527
|
if (context.parentNodeTypes.includes('CreateRoleStmt') || context.parentNodeTypes.includes('AlterRoleStmt')) {
|
|
@@ -5582,7 +5596,7 @@ class Deparser {
|
|
|
5582
5596
|
if (this.getNodeType(item) === 'String') {
|
|
5583
5597
|
// Check if this identifier needs quotes to preserve case
|
|
5584
5598
|
const value = itemData.sval;
|
|
5585
|
-
return
|
|
5599
|
+
return quotes_1.QuoteUtils.quoteIdentifier(value);
|
|
5586
5600
|
}
|
|
5587
5601
|
return this.visit(item, context);
|
|
5588
5602
|
});
|
|
@@ -5730,7 +5744,7 @@ class Deparser {
|
|
|
5730
5744
|
return `${node.defname.toUpperCase()} ${argValue}`;
|
|
5731
5745
|
}
|
|
5732
5746
|
const quotedValue = typeof argValue === 'string'
|
|
5733
|
-
?
|
|
5747
|
+
? quotes_1.QuoteUtils.escape(argValue)
|
|
5734
5748
|
: argValue;
|
|
5735
5749
|
return `${node.defname} ${quotedValue}`;
|
|
5736
5750
|
}
|
|
@@ -5792,7 +5806,7 @@ class Deparser {
|
|
|
5792
5806
|
return `${node.defname}=${argValue}`;
|
|
5793
5807
|
}
|
|
5794
5808
|
const quotedValue = typeof argValue === 'string'
|
|
5795
|
-
?
|
|
5809
|
+
? quotes_1.QuoteUtils.escape(argValue)
|
|
5796
5810
|
: argValue;
|
|
5797
5811
|
return `${node.defname} = ${quotedValue}`;
|
|
5798
5812
|
}
|
|
@@ -5830,12 +5844,12 @@ class Deparser {
|
|
|
5830
5844
|
// Handle boolean flags (no arguments) - preserve quoted case
|
|
5831
5845
|
if (['hashes', 'merges'].includes(node.defname.toLowerCase())) {
|
|
5832
5846
|
if (node.defname !== node.defname.toLowerCase() && node.defname !== node.defname.toUpperCase()) {
|
|
5833
|
-
return
|
|
5847
|
+
return quotes_1.QuoteUtils.quoteIdentifier(node.defname);
|
|
5834
5848
|
}
|
|
5835
5849
|
return preservedName.toUpperCase();
|
|
5836
5850
|
}
|
|
5837
5851
|
// Handle CREATE AGGREGATE quoted identifiers - preserve quotes when needed
|
|
5838
|
-
const quotedDefname =
|
|
5852
|
+
const quotedDefname = quotes_1.QuoteUtils.quoteIdentifier(node.defname);
|
|
5839
5853
|
if (quotedDefname !== node.defname) {
|
|
5840
5854
|
if (node.arg) {
|
|
5841
5855
|
if (this.getNodeType(node.arg) === 'String') {
|
|
@@ -5888,7 +5902,7 @@ class Deparser {
|
|
|
5888
5902
|
}
|
|
5889
5903
|
}
|
|
5890
5904
|
const quotedValue = typeof argValue === 'string'
|
|
5891
|
-
?
|
|
5905
|
+
? quotes_1.QuoteUtils.escape(argValue)
|
|
5892
5906
|
: argValue;
|
|
5893
5907
|
return `${node.defname} = ${quotedValue}`;
|
|
5894
5908
|
}
|
|
@@ -5896,7 +5910,7 @@ class Deparser {
|
|
|
5896
5910
|
if (context.parentNodeTypes.includes('DefineStmt') && !node.arg) {
|
|
5897
5911
|
// Check if the original defname appears to be quoted (mixed case that's not all upper/lower)
|
|
5898
5912
|
if (node.defname !== node.defname.toLowerCase() && node.defname !== node.defname.toUpperCase()) {
|
|
5899
|
-
return
|
|
5913
|
+
return quotes_1.QuoteUtils.quoteIdentifier(node.defname);
|
|
5900
5914
|
}
|
|
5901
5915
|
}
|
|
5902
5916
|
return node.defname.toUpperCase();
|
|
@@ -6080,7 +6094,7 @@ class Deparser {
|
|
|
6080
6094
|
case 'REPLICA_IDENTITY_INDEX':
|
|
6081
6095
|
output.push('USING', 'INDEX');
|
|
6082
6096
|
if (node.name) {
|
|
6083
|
-
output.push(
|
|
6097
|
+
output.push(quotes_1.QuoteUtils.quoteIdentifier(node.name));
|
|
6084
6098
|
}
|
|
6085
6099
|
break;
|
|
6086
6100
|
default:
|
|
@@ -6139,7 +6153,7 @@ class Deparser {
|
|
|
6139
6153
|
output.push('IF', 'EXISTS');
|
|
6140
6154
|
}
|
|
6141
6155
|
if (node.name) {
|
|
6142
|
-
output.push(
|
|
6156
|
+
output.push(quotes_1.QuoteUtils.quoteIdentifier(node.name));
|
|
6143
6157
|
}
|
|
6144
6158
|
if (node.behavior === 'DROP_CASCADE') {
|
|
6145
6159
|
output.push('CASCADE');
|
|
@@ -6148,7 +6162,7 @@ class Deparser {
|
|
|
6148
6162
|
case 'AT_ValidateConstraint':
|
|
6149
6163
|
output.push('VALIDATE', 'CONSTRAINT');
|
|
6150
6164
|
if (node.name) {
|
|
6151
|
-
output.push(
|
|
6165
|
+
output.push(quotes_1.QuoteUtils.quoteIdentifier(node.name));
|
|
6152
6166
|
}
|
|
6153
6167
|
break;
|
|
6154
6168
|
case 'C':
|
|
@@ -6165,7 +6179,7 @@ class Deparser {
|
|
|
6165
6179
|
output.push('IF', 'EXISTS');
|
|
6166
6180
|
}
|
|
6167
6181
|
if (node.name) {
|
|
6168
|
-
output.push(
|
|
6182
|
+
output.push(quotes_1.QuoteUtils.quoteIdentifier(node.name));
|
|
6169
6183
|
}
|
|
6170
6184
|
if (node.behavior === 'DROP_CASCADE') {
|
|
6171
6185
|
output.push('CASCADE');
|
|
@@ -6174,7 +6188,7 @@ class Deparser {
|
|
|
6174
6188
|
case 'V':
|
|
6175
6189
|
output.push('VALIDATE', 'CONSTRAINT');
|
|
6176
6190
|
if (node.name) {
|
|
6177
|
-
output.push(
|
|
6191
|
+
output.push(quotes_1.QuoteUtils.quoteIdentifier(node.name));
|
|
6178
6192
|
}
|
|
6179
6193
|
break;
|
|
6180
6194
|
case 'O':
|
|
@@ -6526,7 +6540,7 @@ class Deparser {
|
|
|
6526
6540
|
output.push('NULL');
|
|
6527
6541
|
}
|
|
6528
6542
|
else if (node.comment) {
|
|
6529
|
-
output.push(
|
|
6543
|
+
output.push(quotes_1.QuoteUtils.formatEString(node.comment));
|
|
6530
6544
|
}
|
|
6531
6545
|
return output.join(' ');
|
|
6532
6546
|
}
|
|
@@ -6563,7 +6577,7 @@ class Deparser {
|
|
|
6563
6577
|
const output = [];
|
|
6564
6578
|
const initialParts = ['CREATE', 'POLICY'];
|
|
6565
6579
|
if (node.policy_name) {
|
|
6566
|
-
initialParts.push(
|
|
6580
|
+
initialParts.push(quotes_1.QuoteUtils.quoteIdentifier(node.policy_name));
|
|
6567
6581
|
}
|
|
6568
6582
|
output.push(initialParts.join(' '));
|
|
6569
6583
|
// Add ON clause on new line in pretty mode
|
|
@@ -6640,7 +6654,7 @@ class Deparser {
|
|
|
6640
6654
|
AlterPolicyStmt(node, context) {
|
|
6641
6655
|
const output = ['ALTER', 'POLICY'];
|
|
6642
6656
|
if (node.policy_name) {
|
|
6643
|
-
output.push(
|
|
6657
|
+
output.push(quotes_1.QuoteUtils.quoteIdentifier(node.policy_name));
|
|
6644
6658
|
}
|
|
6645
6659
|
if (node.table) {
|
|
6646
6660
|
output.push('ON');
|
|
@@ -6676,7 +6690,7 @@ class Deparser {
|
|
|
6676
6690
|
}
|
|
6677
6691
|
output.push('SERVER');
|
|
6678
6692
|
if (node.servername) {
|
|
6679
|
-
output.push(
|
|
6693
|
+
output.push(quotes_1.QuoteUtils.quoteIdentifier(node.servername));
|
|
6680
6694
|
}
|
|
6681
6695
|
if (node.options && node.options.length > 0) {
|
|
6682
6696
|
output.push('OPTIONS');
|
|
@@ -6724,7 +6738,7 @@ class Deparser {
|
|
|
6724
6738
|
CreatePublicationStmt(node, context) {
|
|
6725
6739
|
const output = ['CREATE', 'PUBLICATION'];
|
|
6726
6740
|
if (node.pubname) {
|
|
6727
|
-
output.push(
|
|
6741
|
+
output.push(quotes_1.QuoteUtils.quoteIdentifier(node.pubname));
|
|
6728
6742
|
}
|
|
6729
6743
|
if (node.pubobjects && node.pubobjects.length > 0) {
|
|
6730
6744
|
output.push('FOR', 'TABLE');
|
|
@@ -6744,7 +6758,7 @@ class Deparser {
|
|
|
6744
6758
|
CreateSubscriptionStmt(node, context) {
|
|
6745
6759
|
const output = ['CREATE', 'SUBSCRIPTION'];
|
|
6746
6760
|
if (node.subname) {
|
|
6747
|
-
output.push(
|
|
6761
|
+
output.push(quotes_1.QuoteUtils.quoteIdentifier(node.subname));
|
|
6748
6762
|
}
|
|
6749
6763
|
output.push('CONNECTION');
|
|
6750
6764
|
if (node.conninfo) {
|
|
@@ -6765,7 +6779,7 @@ class Deparser {
|
|
|
6765
6779
|
AlterPublicationStmt(node, context) {
|
|
6766
6780
|
const output = ['ALTER', 'PUBLICATION'];
|
|
6767
6781
|
if (node.pubname) {
|
|
6768
|
-
output.push(
|
|
6782
|
+
output.push(quotes_1.QuoteUtils.quoteIdentifier(node.pubname));
|
|
6769
6783
|
}
|
|
6770
6784
|
if (node.action) {
|
|
6771
6785
|
switch (node.action) {
|
|
@@ -6800,7 +6814,7 @@ class Deparser {
|
|
|
6800
6814
|
AlterSubscriptionStmt(node, context) {
|
|
6801
6815
|
const output = ['ALTER', 'SUBSCRIPTION'];
|
|
6802
6816
|
if (node.subname) {
|
|
6803
|
-
output.push(
|
|
6817
|
+
output.push(quotes_1.QuoteUtils.quoteIdentifier(node.subname));
|
|
6804
6818
|
}
|
|
6805
6819
|
if (node.kind) {
|
|
6806
6820
|
switch (node.kind) {
|
|
@@ -6846,7 +6860,7 @@ class Deparser {
|
|
|
6846
6860
|
output.push('IF EXISTS');
|
|
6847
6861
|
}
|
|
6848
6862
|
if (node.subname) {
|
|
6849
|
-
output.push(
|
|
6863
|
+
output.push(quotes_1.QuoteUtils.quoteIdentifier(node.subname));
|
|
6850
6864
|
}
|
|
6851
6865
|
if (node.behavior) {
|
|
6852
6866
|
switch (node.behavior) {
|
|
@@ -7091,7 +7105,7 @@ class Deparser {
|
|
|
7091
7105
|
ClosePortalStmt(node, context) {
|
|
7092
7106
|
const output = ['CLOSE'];
|
|
7093
7107
|
if (node.portalname) {
|
|
7094
|
-
output.push(
|
|
7108
|
+
output.push(quotes_1.QuoteUtils.quoteIdentifier(node.portalname));
|
|
7095
7109
|
}
|
|
7096
7110
|
else {
|
|
7097
7111
|
output.push('ALL');
|
|
@@ -7149,7 +7163,7 @@ class Deparser {
|
|
|
7149
7163
|
output.push('ALL');
|
|
7150
7164
|
}
|
|
7151
7165
|
if (node.portalname) {
|
|
7152
|
-
output.push(
|
|
7166
|
+
output.push(quotes_1.QuoteUtils.quoteIdentifier(node.portalname));
|
|
7153
7167
|
}
|
|
7154
7168
|
return output.join(' ');
|
|
7155
7169
|
}
|
|
@@ -7219,7 +7233,7 @@ class Deparser {
|
|
|
7219
7233
|
AlterFdwStmt(node, context) {
|
|
7220
7234
|
const output = ['ALTER', 'FOREIGN', 'DATA', 'WRAPPER'];
|
|
7221
7235
|
if (node.fdwname) {
|
|
7222
|
-
output.push(
|
|
7236
|
+
output.push(quotes_1.QuoteUtils.quoteIdentifier(node.fdwname));
|
|
7223
7237
|
}
|
|
7224
7238
|
if (node.func_options && node.func_options.length > 0) {
|
|
7225
7239
|
const fdwContext = context.spawn('AlterFdwStmt');
|
|
@@ -7240,16 +7254,16 @@ class Deparser {
|
|
|
7240
7254
|
output.push('IF', 'NOT', 'EXISTS');
|
|
7241
7255
|
}
|
|
7242
7256
|
if (node.servername) {
|
|
7243
|
-
output.push(
|
|
7257
|
+
output.push(quotes_1.QuoteUtils.quoteIdentifier(node.servername));
|
|
7244
7258
|
}
|
|
7245
7259
|
if (node.servertype) {
|
|
7246
|
-
output.push('TYPE',
|
|
7260
|
+
output.push('TYPE', quotes_1.QuoteUtils.escape(node.servertype));
|
|
7247
7261
|
}
|
|
7248
7262
|
if (node.version) {
|
|
7249
|
-
output.push('VERSION',
|
|
7263
|
+
output.push('VERSION', quotes_1.QuoteUtils.escape(node.version));
|
|
7250
7264
|
}
|
|
7251
7265
|
if (node.fdwname) {
|
|
7252
|
-
output.push('FOREIGN', 'DATA', 'WRAPPER',
|
|
7266
|
+
output.push('FOREIGN', 'DATA', 'WRAPPER', quotes_1.QuoteUtils.quoteIdentifier(node.fdwname));
|
|
7253
7267
|
}
|
|
7254
7268
|
if (node.options && node.options.length > 0) {
|
|
7255
7269
|
output.push('OPTIONS');
|
|
@@ -7264,10 +7278,10 @@ class Deparser {
|
|
|
7264
7278
|
AlterForeignServerStmt(node, context) {
|
|
7265
7279
|
const output = ['ALTER', 'SERVER'];
|
|
7266
7280
|
if (node.servername) {
|
|
7267
|
-
output.push(
|
|
7281
|
+
output.push(quotes_1.QuoteUtils.quoteIdentifier(node.servername));
|
|
7268
7282
|
}
|
|
7269
7283
|
if (node.version) {
|
|
7270
|
-
output.push('VERSION',
|
|
7284
|
+
output.push('VERSION', quotes_1.QuoteUtils.escape(node.version));
|
|
7271
7285
|
}
|
|
7272
7286
|
if (node.options && node.options.length > 0) {
|
|
7273
7287
|
output.push('OPTIONS');
|
|
@@ -7289,7 +7303,7 @@ class Deparser {
|
|
|
7289
7303
|
}
|
|
7290
7304
|
output.push('SERVER');
|
|
7291
7305
|
if (node.servername) {
|
|
7292
|
-
output.push(
|
|
7306
|
+
output.push(quotes_1.QuoteUtils.quoteIdentifier(node.servername));
|
|
7293
7307
|
}
|
|
7294
7308
|
if (node.options && node.options.length > 0) {
|
|
7295
7309
|
output.push('OPTIONS');
|
|
@@ -7313,14 +7327,14 @@ class Deparser {
|
|
|
7313
7327
|
}
|
|
7314
7328
|
output.push('SERVER');
|
|
7315
7329
|
if (node.servername) {
|
|
7316
|
-
output.push(
|
|
7330
|
+
output.push(quotes_1.QuoteUtils.quoteIdentifier(node.servername));
|
|
7317
7331
|
}
|
|
7318
7332
|
return output.join(' ');
|
|
7319
7333
|
}
|
|
7320
7334
|
ImportForeignSchemaStmt(node, context) {
|
|
7321
7335
|
const output = ['IMPORT', 'FOREIGN', 'SCHEMA'];
|
|
7322
7336
|
if (node.remote_schema) {
|
|
7323
|
-
output.push(
|
|
7337
|
+
output.push(quotes_1.QuoteUtils.quoteIdentifier(node.remote_schema));
|
|
7324
7338
|
}
|
|
7325
7339
|
if (node.list_type) {
|
|
7326
7340
|
switch (node.list_type) {
|
|
@@ -7346,11 +7360,11 @@ class Deparser {
|
|
|
7346
7360
|
}
|
|
7347
7361
|
output.push('FROM', 'SERVER');
|
|
7348
7362
|
if (node.server_name) {
|
|
7349
|
-
output.push(
|
|
7363
|
+
output.push(quotes_1.QuoteUtils.quoteIdentifier(node.server_name));
|
|
7350
7364
|
}
|
|
7351
7365
|
output.push('INTO');
|
|
7352
7366
|
if (node.local_schema) {
|
|
7353
|
-
output.push(
|
|
7367
|
+
output.push(quotes_1.QuoteUtils.quoteIdentifier(node.local_schema));
|
|
7354
7368
|
}
|
|
7355
7369
|
if (node.options && node.options.length > 0) {
|
|
7356
7370
|
const importSchemaContext = context.spawn('ImportForeignSchemaStmt');
|
|
@@ -7364,7 +7378,7 @@ class Deparser {
|
|
|
7364
7378
|
if (node.relation) {
|
|
7365
7379
|
output.push(this.RangeVar(node.relation, context));
|
|
7366
7380
|
if (node.indexname) {
|
|
7367
|
-
output.push('USING',
|
|
7381
|
+
output.push('USING', quotes_1.QuoteUtils.quoteIdentifier(node.indexname));
|
|
7368
7382
|
}
|
|
7369
7383
|
}
|
|
7370
7384
|
if (node.params && node.params.length > 0) {
|
|
@@ -7428,7 +7442,7 @@ class Deparser {
|
|
|
7428
7442
|
output.push(this.RangeVar(node.relation, context));
|
|
7429
7443
|
}
|
|
7430
7444
|
if (node.name) {
|
|
7431
|
-
output.push(
|
|
7445
|
+
output.push(quotes_1.QuoteUtils.quoteIdentifier(node.name));
|
|
7432
7446
|
}
|
|
7433
7447
|
return output.join(' ');
|
|
7434
7448
|
}
|
|
@@ -7468,7 +7482,7 @@ class Deparser {
|
|
|
7468
7482
|
if (!node.dbname) {
|
|
7469
7483
|
throw new Error('CreatedbStmt requires dbname');
|
|
7470
7484
|
}
|
|
7471
|
-
output.push(
|
|
7485
|
+
output.push(quotes_1.QuoteUtils.quoteIdentifier(node.dbname));
|
|
7472
7486
|
if (node.options && node.options.length > 0) {
|
|
7473
7487
|
const options = list_utils_1.ListUtils.unwrapList(node.options)
|
|
7474
7488
|
.map(option => this.visit(option, context))
|
|
@@ -7485,7 +7499,7 @@ class Deparser {
|
|
|
7485
7499
|
if (!node.dbname) {
|
|
7486
7500
|
throw new Error('DropdbStmt requires dbname');
|
|
7487
7501
|
}
|
|
7488
|
-
output.push(
|
|
7502
|
+
output.push(quotes_1.QuoteUtils.quoteIdentifier(node.dbname));
|
|
7489
7503
|
if (node.options && node.options.length > 0) {
|
|
7490
7504
|
const options = list_utils_1.ListUtils.unwrapList(node.options)
|
|
7491
7505
|
.map(option => this.visit(option, context))
|
|
@@ -7583,7 +7597,7 @@ class Deparser {
|
|
|
7583
7597
|
case 'OBJECT_POLICY':
|
|
7584
7598
|
output.push('POLICY');
|
|
7585
7599
|
if (node.subname) {
|
|
7586
|
-
output.push(
|
|
7600
|
+
output.push(quotes_1.QuoteUtils.quoteIdentifier(node.subname));
|
|
7587
7601
|
}
|
|
7588
7602
|
break;
|
|
7589
7603
|
case 'OBJECT_PUBLICATION':
|
|
@@ -7641,7 +7655,7 @@ class Deparser {
|
|
|
7641
7655
|
}
|
|
7642
7656
|
// Handle OBJECT_RULE special case: rule_name ON table_name format
|
|
7643
7657
|
if (node.renameType === 'OBJECT_RULE' && node.subname && node.relation) {
|
|
7644
|
-
output.push(
|
|
7658
|
+
output.push(quotes_1.QuoteUtils.quoteIdentifier(node.subname));
|
|
7645
7659
|
output.push('ON');
|
|
7646
7660
|
output.push(this.RangeVar(node.relation, context));
|
|
7647
7661
|
}
|
|
@@ -7660,7 +7674,7 @@ class Deparser {
|
|
|
7660
7674
|
if (items.length === 2) {
|
|
7661
7675
|
const accessMethod = items[0].String?.sval || '';
|
|
7662
7676
|
const objectName = items[1].String?.sval || '';
|
|
7663
|
-
output.push(`${
|
|
7677
|
+
output.push(`${quotes_1.QuoteUtils.quoteIdentifier(objectName)} USING ${accessMethod}`);
|
|
7664
7678
|
}
|
|
7665
7679
|
else {
|
|
7666
7680
|
output.push(this.visit(node.object, context));
|
|
@@ -7681,19 +7695,19 @@ class Deparser {
|
|
|
7681
7695
|
}
|
|
7682
7696
|
}
|
|
7683
7697
|
if (node.renameType === 'OBJECT_COLUMN' && node.subname) {
|
|
7684
|
-
output.push('RENAME COLUMN',
|
|
7698
|
+
output.push('RENAME COLUMN', quotes_1.QuoteUtils.quoteIdentifier(node.subname), 'TO');
|
|
7685
7699
|
}
|
|
7686
7700
|
else if (node.renameType === 'OBJECT_DOMCONSTRAINT' && node.subname) {
|
|
7687
|
-
output.push('RENAME CONSTRAINT',
|
|
7701
|
+
output.push('RENAME CONSTRAINT', quotes_1.QuoteUtils.quoteIdentifier(node.subname), 'TO');
|
|
7688
7702
|
}
|
|
7689
7703
|
else if (node.renameType === 'OBJECT_TABCONSTRAINT' && node.subname) {
|
|
7690
|
-
output.push('RENAME CONSTRAINT',
|
|
7704
|
+
output.push('RENAME CONSTRAINT', quotes_1.QuoteUtils.quoteIdentifier(node.subname), 'TO');
|
|
7691
7705
|
}
|
|
7692
7706
|
else if (node.renameType === 'OBJECT_ATTRIBUTE' && node.subname) {
|
|
7693
|
-
output.push('RENAME ATTRIBUTE',
|
|
7707
|
+
output.push('RENAME ATTRIBUTE', quotes_1.QuoteUtils.quoteIdentifier(node.subname), 'TO');
|
|
7694
7708
|
}
|
|
7695
7709
|
else if (node.renameType === 'OBJECT_ROLE' && node.subname) {
|
|
7696
|
-
output.push(
|
|
7710
|
+
output.push(quotes_1.QuoteUtils.quoteIdentifier(node.subname), 'RENAME TO');
|
|
7697
7711
|
}
|
|
7698
7712
|
else if (node.renameType === 'OBJECT_SCHEMA' && node.subname) {
|
|
7699
7713
|
output.push(this.quoteIfNeeded(node.subname), 'RENAME TO');
|
|
@@ -7707,7 +7721,7 @@ class Deparser {
|
|
|
7707
7721
|
if (!node.newname) {
|
|
7708
7722
|
throw new Error('RenameStmt requires newname');
|
|
7709
7723
|
}
|
|
7710
|
-
output.push(
|
|
7724
|
+
output.push(quotes_1.QuoteUtils.quoteIdentifier(node.newname));
|
|
7711
7725
|
// Handle CASCADE/RESTRICT behavior for RENAME operations
|
|
7712
7726
|
if (node.behavior === 'DROP_CASCADE') {
|
|
7713
7727
|
output.push('CASCADE');
|
|
@@ -7730,7 +7744,7 @@ class Deparser {
|
|
|
7730
7744
|
if (items.length === 2) {
|
|
7731
7745
|
const accessMethod = items[0].String?.sval || '';
|
|
7732
7746
|
const objectName = items[1].String?.sval || '';
|
|
7733
|
-
output.push(`${
|
|
7747
|
+
output.push(`${quotes_1.QuoteUtils.quoteIdentifier(objectName)} USING ${accessMethod}`);
|
|
7734
7748
|
}
|
|
7735
7749
|
else {
|
|
7736
7750
|
output.push(this.visit(node.object, context));
|
|
@@ -8000,7 +8014,7 @@ class Deparser {
|
|
|
8000
8014
|
SecLabelStmt(node, context) {
|
|
8001
8015
|
const output = ['SECURITY LABEL'];
|
|
8002
8016
|
if (node.provider) {
|
|
8003
|
-
output.push('FOR',
|
|
8017
|
+
output.push('FOR', quotes_1.QuoteUtils.quoteIdentifier(node.provider));
|
|
8004
8018
|
}
|
|
8005
8019
|
output.push('ON');
|
|
8006
8020
|
if (node.objtype) {
|
|
@@ -8153,7 +8167,7 @@ class Deparser {
|
|
|
8153
8167
|
}
|
|
8154
8168
|
output.push('LANGUAGE');
|
|
8155
8169
|
if (node.plname) {
|
|
8156
|
-
output.push(
|
|
8170
|
+
output.push(quotes_1.QuoteUtils.quoteIdentifier(node.plname));
|
|
8157
8171
|
}
|
|
8158
8172
|
if (node.plhandler && node.plhandler.length > 0) {
|
|
8159
8173
|
output.push('HANDLER');
|
|
@@ -8189,7 +8203,7 @@ class Deparser {
|
|
|
8189
8203
|
}
|
|
8190
8204
|
output.push('LANGUAGE');
|
|
8191
8205
|
if (node.lang) {
|
|
8192
|
-
output.push(
|
|
8206
|
+
output.push(quotes_1.QuoteUtils.quoteIdentifier(node.lang));
|
|
8193
8207
|
}
|
|
8194
8208
|
output.push('(');
|
|
8195
8209
|
const transforms = [];
|
|
@@ -8217,7 +8231,7 @@ class Deparser {
|
|
|
8217
8231
|
}
|
|
8218
8232
|
output.push('TRIGGER');
|
|
8219
8233
|
if (node.trigname) {
|
|
8220
|
-
output.push(
|
|
8234
|
+
output.push(quotes_1.QuoteUtils.quoteIdentifier(node.trigname));
|
|
8221
8235
|
}
|
|
8222
8236
|
if (context.isPretty()) {
|
|
8223
8237
|
const components = [];
|
|
@@ -8381,14 +8395,14 @@ class Deparser {
|
|
|
8381
8395
|
output.push('OLD TABLE AS');
|
|
8382
8396
|
}
|
|
8383
8397
|
if (node.name) {
|
|
8384
|
-
output.push(
|
|
8398
|
+
output.push(quotes_1.QuoteUtils.quoteIdentifier(node.name));
|
|
8385
8399
|
}
|
|
8386
8400
|
return output.join(' ');
|
|
8387
8401
|
}
|
|
8388
8402
|
CreateEventTrigStmt(node, context) {
|
|
8389
8403
|
const output = ['CREATE EVENT TRIGGER'];
|
|
8390
8404
|
if (node.trigname) {
|
|
8391
|
-
output.push(
|
|
8405
|
+
output.push(quotes_1.QuoteUtils.quoteIdentifier(node.trigname));
|
|
8392
8406
|
}
|
|
8393
8407
|
output.push('ON');
|
|
8394
8408
|
if (node.eventname) {
|
|
@@ -8414,7 +8428,7 @@ class Deparser {
|
|
|
8414
8428
|
AlterEventTrigStmt(node, context) {
|
|
8415
8429
|
const output = ['ALTER EVENT TRIGGER'];
|
|
8416
8430
|
if (node.trigname) {
|
|
8417
|
-
output.push(
|
|
8431
|
+
output.push(quotes_1.QuoteUtils.quoteIdentifier(node.trigname));
|
|
8418
8432
|
}
|
|
8419
8433
|
if (node.tgenabled) {
|
|
8420
8434
|
switch (node.tgenabled) {
|
|
@@ -8549,11 +8563,11 @@ class Deparser {
|
|
|
8549
8563
|
}
|
|
8550
8564
|
output.push('ALL', 'IN', 'TABLESPACE');
|
|
8551
8565
|
if (node.orig_tablespacename) {
|
|
8552
|
-
output.push(
|
|
8566
|
+
output.push(quotes_1.QuoteUtils.quoteIdentifier(node.orig_tablespacename));
|
|
8553
8567
|
}
|
|
8554
8568
|
output.push('SET', 'TABLESPACE');
|
|
8555
8569
|
if (node.new_tablespacename) {
|
|
8556
|
-
output.push(
|
|
8570
|
+
output.push(quotes_1.QuoteUtils.quoteIdentifier(node.new_tablespacename));
|
|
8557
8571
|
}
|
|
8558
8572
|
if (node.nowait) {
|
|
8559
8573
|
output.push('NOWAIT');
|
|
@@ -8577,10 +8591,10 @@ class Deparser {
|
|
|
8577
8591
|
const sequenceName = [];
|
|
8578
8592
|
const seq = node.sequence;
|
|
8579
8593
|
if (seq.schemaname) {
|
|
8580
|
-
sequenceName.push(
|
|
8594
|
+
sequenceName.push(quotes_1.QuoteUtils.quoteIdentifier(seq.schemaname));
|
|
8581
8595
|
}
|
|
8582
8596
|
if (seq.relname) {
|
|
8583
|
-
sequenceName.push(
|
|
8597
|
+
sequenceName.push(quotes_1.QuoteUtils.quoteIdentifier(seq.relname));
|
|
8584
8598
|
}
|
|
8585
8599
|
output.push(sequenceName.join('.'));
|
|
8586
8600
|
}
|
|
@@ -8614,10 +8628,10 @@ class Deparser {
|
|
|
8614
8628
|
const sequenceName = [];
|
|
8615
8629
|
const seq = node.sequence;
|
|
8616
8630
|
if (seq.schemaname) {
|
|
8617
|
-
sequenceName.push(
|
|
8631
|
+
sequenceName.push(quotes_1.QuoteUtils.quoteIdentifier(seq.schemaname));
|
|
8618
8632
|
}
|
|
8619
8633
|
if (seq.relname) {
|
|
8620
|
-
sequenceName.push(
|
|
8634
|
+
sequenceName.push(quotes_1.QuoteUtils.quoteIdentifier(seq.relname));
|
|
8621
8635
|
}
|
|
8622
8636
|
output.push(sequenceName.join('.'));
|
|
8623
8637
|
}
|
|
@@ -8964,7 +8978,7 @@ class Deparser {
|
|
|
8964
8978
|
}
|
|
8965
8979
|
aliasname(node, context) {
|
|
8966
8980
|
if (typeof node === 'string') {
|
|
8967
|
-
return
|
|
8981
|
+
return quotes_1.QuoteUtils.quoteIdentifier(node);
|
|
8968
8982
|
}
|
|
8969
8983
|
return this.visit(node, context);
|
|
8970
8984
|
}
|
|
@@ -8996,7 +9010,7 @@ class Deparser {
|
|
|
8996
9010
|
const defName = defElem.defname;
|
|
8997
9011
|
const defValue = defElem.arg;
|
|
8998
9012
|
if (defName && defValue) {
|
|
8999
|
-
const quotedDefName =
|
|
9013
|
+
const quotedDefName = quotes_1.QuoteUtils.quoteIdentifier(defName);
|
|
9000
9014
|
const preservedDefName = quotedDefName !== defName ? quotedDefName : this.preserveOperatorDefElemCase(defName);
|
|
9001
9015
|
if ((defName.toLowerCase() === 'commutator' || defName.toLowerCase() === 'negator') && defValue.List) {
|
|
9002
9016
|
const listItems = list_utils_1.ListUtils.unwrapList(defValue.List.items);
|
|
@@ -9013,7 +9027,7 @@ class Deparser {
|
|
|
9013
9027
|
else if (defName && !defValue) {
|
|
9014
9028
|
// Handle boolean flags like HASHES, MERGES - preserve original case
|
|
9015
9029
|
if (defName === 'Hashes' || defName === 'Merges') {
|
|
9016
|
-
return
|
|
9030
|
+
return quotes_1.QuoteUtils.quoteIdentifier(defName);
|
|
9017
9031
|
}
|
|
9018
9032
|
return this.preserveOperatorDefElemCase(defName).toUpperCase();
|
|
9019
9033
|
}
|
|
@@ -9152,7 +9166,7 @@ class Deparser {
|
|
|
9152
9166
|
const defName = defElem.defname;
|
|
9153
9167
|
const defValue = defElem.arg;
|
|
9154
9168
|
if (defName && defValue) {
|
|
9155
|
-
const quotedDefName =
|
|
9169
|
+
const quotedDefName = quotes_1.QuoteUtils.quoteIdentifier(defName);
|
|
9156
9170
|
const preservedDefName = quotedDefName !== defName ? quotedDefName : defName;
|
|
9157
9171
|
// Handle String arguments with single quotes for string literals
|
|
9158
9172
|
if (defValue.String) {
|
|
@@ -9308,7 +9322,7 @@ class Deparser {
|
|
|
9308
9322
|
AlterDatabaseStmt(node, context) {
|
|
9309
9323
|
const output = ['ALTER', 'DATABASE'];
|
|
9310
9324
|
if (node.dbname) {
|
|
9311
|
-
output.push(
|
|
9325
|
+
output.push(quotes_1.QuoteUtils.quoteIdentifier(node.dbname));
|
|
9312
9326
|
}
|
|
9313
9327
|
if (node.options && node.options.length > 0) {
|
|
9314
9328
|
const options = list_utils_1.ListUtils.unwrapList(node.options).map(opt => this.visit(opt, context));
|
|
@@ -9319,7 +9333,7 @@ class Deparser {
|
|
|
9319
9333
|
AlterDatabaseRefreshCollStmt(node, context) {
|
|
9320
9334
|
const output = ['ALTER', 'DATABASE'];
|
|
9321
9335
|
if (node.dbname) {
|
|
9322
|
-
output.push(
|
|
9336
|
+
output.push(quotes_1.QuoteUtils.quoteIdentifier(node.dbname));
|
|
9323
9337
|
}
|
|
9324
9338
|
output.push('REFRESH', 'COLLATION', 'VERSION');
|
|
9325
9339
|
return output.join(' ');
|
|
@@ -9327,7 +9341,7 @@ class Deparser {
|
|
|
9327
9341
|
AlterDatabaseSetStmt(node, context) {
|
|
9328
9342
|
const output = ['ALTER', 'DATABASE'];
|
|
9329
9343
|
if (node.dbname) {
|
|
9330
|
-
output.push(
|
|
9344
|
+
output.push(quotes_1.QuoteUtils.quoteIdentifier(node.dbname));
|
|
9331
9345
|
}
|
|
9332
9346
|
if (node.setstmt) {
|
|
9333
9347
|
const setClause = this.VariableSetStmt(node.setstmt, context);
|
|
@@ -9338,7 +9352,7 @@ class Deparser {
|
|
|
9338
9352
|
DeclareCursorStmt(node, context) {
|
|
9339
9353
|
const output = ['DECLARE'];
|
|
9340
9354
|
if (node.portalname) {
|
|
9341
|
-
output.push(
|
|
9355
|
+
output.push(quotes_1.QuoteUtils.quoteIdentifier(node.portalname));
|
|
9342
9356
|
}
|
|
9343
9357
|
// Handle cursor options before CURSOR keyword
|
|
9344
9358
|
const cursorOptions = [];
|
|
@@ -9380,7 +9394,7 @@ class Deparser {
|
|
|
9380
9394
|
else if (node.pubobjtype === 'PUBLICATIONOBJ_TABLES_IN_SCHEMA') {
|
|
9381
9395
|
output.push('TABLES IN SCHEMA');
|
|
9382
9396
|
if (node.name) {
|
|
9383
|
-
output.push(
|
|
9397
|
+
output.push(quotes_1.QuoteUtils.quoteIdentifier(node.name));
|
|
9384
9398
|
}
|
|
9385
9399
|
}
|
|
9386
9400
|
else if (node.pubobjtype === 'PUBLICATIONOBJ_TABLES_IN_CUR_SCHEMA') {
|
|
@@ -9406,7 +9420,7 @@ class Deparser {
|
|
|
9406
9420
|
CreateAmStmt(node, context) {
|
|
9407
9421
|
const output = ['CREATE', 'ACCESS', 'METHOD'];
|
|
9408
9422
|
if (node.amname) {
|
|
9409
|
-
output.push(
|
|
9423
|
+
output.push(quotes_1.QuoteUtils.quoteIdentifier(node.amname));
|
|
9410
9424
|
}
|
|
9411
9425
|
output.push('TYPE');
|
|
9412
9426
|
switch (node.amtype) {
|
|
@@ -9466,7 +9480,7 @@ class Deparser {
|
|
|
9466
9480
|
}
|
|
9467
9481
|
}
|
|
9468
9482
|
if (node.tableSpaceName) {
|
|
9469
|
-
output.push('TABLESPACE',
|
|
9483
|
+
output.push('TABLESPACE', quotes_1.QuoteUtils.quoteIdentifier(node.tableSpaceName));
|
|
9470
9484
|
}
|
|
9471
9485
|
return output.join(' ');
|
|
9472
9486
|
}
|
|
@@ -9624,7 +9638,7 @@ class Deparser {
|
|
|
9624
9638
|
RangeTableFuncCol(node, context) {
|
|
9625
9639
|
const output = [];
|
|
9626
9640
|
if (node.colname) {
|
|
9627
|
-
output.push(
|
|
9641
|
+
output.push(quotes_1.QuoteUtils.quoteIdentifier(node.colname));
|
|
9628
9642
|
}
|
|
9629
9643
|
if (node.for_ordinality) {
|
|
9630
9644
|
output.push('FOR ORDINALITY');
|
|
@@ -9770,10 +9784,10 @@ class Deparser {
|
|
|
9770
9784
|
if (node.op === 'IS_XMLPI') {
|
|
9771
9785
|
if (node.name && node.args && node.args.length > 0) {
|
|
9772
9786
|
const argStrs = list_utils_1.ListUtils.unwrapList(node.args).map(arg => this.visit(arg, context));
|
|
9773
|
-
return `xmlpi(name ${
|
|
9787
|
+
return `xmlpi(name ${quotes_1.QuoteUtils.quoteIdentifier(node.name)}, ${argStrs.join(', ')})`;
|
|
9774
9788
|
}
|
|
9775
9789
|
else if (node.name) {
|
|
9776
|
-
return `xmlpi(name ${
|
|
9790
|
+
return `xmlpi(name ${quotes_1.QuoteUtils.quoteIdentifier(node.name)})`;
|
|
9777
9791
|
}
|
|
9778
9792
|
else {
|
|
9779
9793
|
return 'XMLPI()';
|
|
@@ -9788,7 +9802,7 @@ class Deparser {
|
|
|
9788
9802
|
output.push('XMLELEMENT');
|
|
9789
9803
|
const elementParts = [];
|
|
9790
9804
|
if (node.name) {
|
|
9791
|
-
elementParts.push(`NAME ${
|
|
9805
|
+
elementParts.push(`NAME ${quotes_1.QuoteUtils.quoteIdentifier(node.name)}`);
|
|
9792
9806
|
}
|
|
9793
9807
|
if (node.named_args && node.named_args.length > 0) {
|
|
9794
9808
|
const namedArgStrs = list_utils_1.ListUtils.unwrapList(node.named_args).map(arg => this.visit(arg, context));
|
|
@@ -9888,7 +9902,7 @@ class Deparser {
|
|
|
9888
9902
|
// Handle name and args for operations that don't have special handling
|
|
9889
9903
|
if (node.op !== 'IS_XMLELEMENT' && node.op !== 'IS_XMLPARSE' && node.op !== 'IS_XMLROOT' && node.op !== 'IS_DOCUMENT') {
|
|
9890
9904
|
if (node.name) {
|
|
9891
|
-
const quotedName =
|
|
9905
|
+
const quotedName = quotes_1.QuoteUtils.quoteIdentifier(node.name);
|
|
9892
9906
|
output.push(`NAME ${quotedName}`);
|
|
9893
9907
|
}
|
|
9894
9908
|
if (node.args && node.args.length > 0) {
|
|
@@ -9909,26 +9923,26 @@ class Deparser {
|
|
|
9909
9923
|
}
|
|
9910
9924
|
schemaname(node, context) {
|
|
9911
9925
|
if (typeof node === 'string') {
|
|
9912
|
-
return
|
|
9926
|
+
return quotes_1.QuoteUtils.quoteIdentifier(node);
|
|
9913
9927
|
}
|
|
9914
9928
|
if (node && node.String && node.String.sval) {
|
|
9915
|
-
return
|
|
9929
|
+
return quotes_1.QuoteUtils.quoteIdentifier(node.String.sval);
|
|
9916
9930
|
}
|
|
9917
9931
|
// Handle other node types without recursion
|
|
9918
9932
|
if (node && typeof node === 'object') {
|
|
9919
9933
|
if (node.sval !== undefined) {
|
|
9920
|
-
return
|
|
9934
|
+
return quotes_1.QuoteUtils.quoteIdentifier(node.sval);
|
|
9921
9935
|
}
|
|
9922
9936
|
// Handle List nodes that might contain schema names
|
|
9923
9937
|
if (node.List && Array.isArray(node.List.items)) {
|
|
9924
9938
|
const items = node.List.items;
|
|
9925
9939
|
if (items.length > 0 && items[0].String && items[0].String.sval) {
|
|
9926
|
-
return
|
|
9940
|
+
return quotes_1.QuoteUtils.quoteIdentifier(items[0].String.sval);
|
|
9927
9941
|
}
|
|
9928
9942
|
}
|
|
9929
9943
|
// For other complex nodes, try to extract string value without recursion
|
|
9930
9944
|
if (node.val !== undefined) {
|
|
9931
|
-
return
|
|
9945
|
+
return quotes_1.QuoteUtils.quoteIdentifier(node.val);
|
|
9932
9946
|
}
|
|
9933
9947
|
return '';
|
|
9934
9948
|
}
|
|
@@ -9991,7 +10005,7 @@ class Deparser {
|
|
|
9991
10005
|
}
|
|
9992
10006
|
output.push('RULE');
|
|
9993
10007
|
if (node.rulename) {
|
|
9994
|
-
output.push(
|
|
10008
|
+
output.push(quotes_1.QuoteUtils.quoteIdentifier(node.rulename));
|
|
9995
10009
|
}
|
|
9996
10010
|
output.push('AS ON');
|
|
9997
10011
|
if (node.event) {
|
|
@@ -10058,42 +10072,42 @@ class Deparser {
|
|
|
10058
10072
|
}
|
|
10059
10073
|
relname(node, context) {
|
|
10060
10074
|
if (typeof node === 'string') {
|
|
10061
|
-
return
|
|
10075
|
+
return quotes_1.QuoteUtils.quoteIdentifier(node);
|
|
10062
10076
|
}
|
|
10063
10077
|
if (node && node.String && node.String.sval) {
|
|
10064
|
-
return
|
|
10078
|
+
return quotes_1.QuoteUtils.quoteIdentifier(node.String.sval);
|
|
10065
10079
|
}
|
|
10066
10080
|
if (node && typeof node === 'object' && node.relname) {
|
|
10067
|
-
return
|
|
10081
|
+
return quotes_1.QuoteUtils.quoteIdentifier(node.relname);
|
|
10068
10082
|
}
|
|
10069
10083
|
return this.visit(node, context);
|
|
10070
10084
|
}
|
|
10071
10085
|
rel(node, context) {
|
|
10072
10086
|
if (typeof node === 'string') {
|
|
10073
|
-
return
|
|
10087
|
+
return quotes_1.QuoteUtils.quoteIdentifier(node);
|
|
10074
10088
|
}
|
|
10075
10089
|
if (node && node.String && node.String.sval) {
|
|
10076
|
-
return
|
|
10090
|
+
return quotes_1.QuoteUtils.quoteIdentifier(node.String.sval);
|
|
10077
10091
|
}
|
|
10078
10092
|
if (node && node.RangeVar) {
|
|
10079
10093
|
return this.RangeVar(node.RangeVar, context);
|
|
10080
10094
|
}
|
|
10081
10095
|
if (node && typeof node === 'object' && node.relname) {
|
|
10082
|
-
return
|
|
10096
|
+
return quotes_1.QuoteUtils.quoteIdentifier(node.relname);
|
|
10083
10097
|
}
|
|
10084
10098
|
return this.visit(node, context);
|
|
10085
10099
|
}
|
|
10086
10100
|
objname(node, context) {
|
|
10087
10101
|
if (typeof node === 'string') {
|
|
10088
|
-
return
|
|
10102
|
+
return quotes_1.QuoteUtils.quoteIdentifier(node);
|
|
10089
10103
|
}
|
|
10090
10104
|
if (node && node.String && node.String.sval) {
|
|
10091
|
-
return
|
|
10105
|
+
return quotes_1.QuoteUtils.quoteIdentifier(node.String.sval);
|
|
10092
10106
|
}
|
|
10093
10107
|
if (Array.isArray(node)) {
|
|
10094
10108
|
const parts = node.map(part => {
|
|
10095
10109
|
if (part && part.String && part.String.sval) {
|
|
10096
|
-
return
|
|
10110
|
+
return quotes_1.QuoteUtils.quoteIdentifier(part.String.sval);
|
|
10097
10111
|
}
|
|
10098
10112
|
return this.visit(part, context);
|
|
10099
10113
|
});
|
|
@@ -10164,7 +10178,7 @@ class Deparser {
|
|
|
10164
10178
|
CurrentOfExpr(node, context) {
|
|
10165
10179
|
const output = ['CURRENT OF'];
|
|
10166
10180
|
if (node.cursor_name) {
|
|
10167
|
-
output.push(
|
|
10181
|
+
output.push(quotes_1.QuoteUtils.quoteIdentifier(node.cursor_name));
|
|
10168
10182
|
}
|
|
10169
10183
|
if (node.cursor_param > 0) {
|
|
10170
10184
|
output.push(`$${node.cursor_param}`);
|
|
@@ -10247,7 +10261,7 @@ class Deparser {
|
|
|
10247
10261
|
if (items.length === 2) {
|
|
10248
10262
|
const schemaName = items[0].String?.sval || '';
|
|
10249
10263
|
const domainName = items[1].String?.sval || '';
|
|
10250
|
-
output.push(
|
|
10264
|
+
output.push(quotes_1.QuoteUtils.quoteQualifiedIdentifier(schemaName, domainName));
|
|
10251
10265
|
}
|
|
10252
10266
|
else {
|
|
10253
10267
|
output.push(this.visit(node.object, context));
|
|
@@ -10259,7 +10273,7 @@ class Deparser {
|
|
|
10259
10273
|
if (items.length === 2) {
|
|
10260
10274
|
const schemaName = items[0].String?.sval || '';
|
|
10261
10275
|
const typeName = items[1].String?.sval || '';
|
|
10262
|
-
output.push(
|
|
10276
|
+
output.push(quotes_1.QuoteUtils.quoteQualifiedIdentifier(schemaName, typeName));
|
|
10263
10277
|
}
|
|
10264
10278
|
else {
|
|
10265
10279
|
output.push(this.visit(node.object, context));
|
|
@@ -10271,7 +10285,7 @@ class Deparser {
|
|
|
10271
10285
|
if (items.length === 2) {
|
|
10272
10286
|
const schemaName = items[0].String?.sval || '';
|
|
10273
10287
|
const conversionName = items[1].String?.sval || '';
|
|
10274
|
-
output.push(
|
|
10288
|
+
output.push(quotes_1.QuoteUtils.quoteQualifiedIdentifier(schemaName, conversionName));
|
|
10275
10289
|
}
|
|
10276
10290
|
else {
|
|
10277
10291
|
output.push(this.visit(node.object, context));
|
|
@@ -10283,7 +10297,7 @@ class Deparser {
|
|
|
10283
10297
|
if (items.length === 2) {
|
|
10284
10298
|
const schemaName = items[0].String?.sval || '';
|
|
10285
10299
|
const parserName = items[1].String?.sval || '';
|
|
10286
|
-
output.push(
|
|
10300
|
+
output.push(quotes_1.QuoteUtils.quoteQualifiedIdentifier(schemaName, parserName));
|
|
10287
10301
|
}
|
|
10288
10302
|
else {
|
|
10289
10303
|
output.push(this.visit(node.object, context));
|
|
@@ -10295,7 +10309,7 @@ class Deparser {
|
|
|
10295
10309
|
if (items.length === 2) {
|
|
10296
10310
|
const schemaName = items[0].String?.sval || '';
|
|
10297
10311
|
const configName = items[1].String?.sval || '';
|
|
10298
|
-
output.push(
|
|
10312
|
+
output.push(quotes_1.QuoteUtils.quoteQualifiedIdentifier(schemaName, configName));
|
|
10299
10313
|
}
|
|
10300
10314
|
else {
|
|
10301
10315
|
output.push(this.visit(node.object, context));
|
|
@@ -10307,7 +10321,7 @@ class Deparser {
|
|
|
10307
10321
|
if (items.length === 2) {
|
|
10308
10322
|
const schemaName = items[0].String?.sval || '';
|
|
10309
10323
|
const templateName = items[1].String?.sval || '';
|
|
10310
|
-
output.push(
|
|
10324
|
+
output.push(quotes_1.QuoteUtils.quoteQualifiedIdentifier(schemaName, templateName));
|
|
10311
10325
|
}
|
|
10312
10326
|
else {
|
|
10313
10327
|
output.push(this.visit(node.object, context));
|
|
@@ -10319,7 +10333,7 @@ class Deparser {
|
|
|
10319
10333
|
if (items.length === 2) {
|
|
10320
10334
|
const schemaName = items[0].String?.sval || '';
|
|
10321
10335
|
const dictionaryName = items[1].String?.sval || '';
|
|
10322
|
-
output.push(
|
|
10336
|
+
output.push(quotes_1.QuoteUtils.quoteQualifiedIdentifier(schemaName, dictionaryName));
|
|
10323
10337
|
}
|
|
10324
10338
|
else {
|
|
10325
10339
|
output.push(this.visit(node.object, context));
|
|
@@ -10331,13 +10345,13 @@ class Deparser {
|
|
|
10331
10345
|
if (items.length === 2) {
|
|
10332
10346
|
const accessMethod = items[0].String?.sval || '';
|
|
10333
10347
|
const opClassName = items[1].String?.sval || '';
|
|
10334
|
-
output.push(`${
|
|
10348
|
+
output.push(`${quotes_1.QuoteUtils.quoteIdentifier(opClassName)} USING ${accessMethod}`);
|
|
10335
10349
|
}
|
|
10336
10350
|
else if (items.length === 3) {
|
|
10337
10351
|
const accessMethod = items[0].String?.sval || '';
|
|
10338
10352
|
const schemaName = items[1].String?.sval || '';
|
|
10339
10353
|
const opClassName = items[2].String?.sval || '';
|
|
10340
|
-
output.push(`${
|
|
10354
|
+
output.push(`${quotes_1.QuoteUtils.quoteQualifiedIdentifier(schemaName, opClassName)} USING ${accessMethod}`);
|
|
10341
10355
|
}
|
|
10342
10356
|
else {
|
|
10343
10357
|
output.push(this.visit(node.object, context));
|
|
@@ -10349,13 +10363,13 @@ class Deparser {
|
|
|
10349
10363
|
if (items.length === 2) {
|
|
10350
10364
|
const accessMethod = items[0].String?.sval || '';
|
|
10351
10365
|
const opFamilyName = items[1].String?.sval || '';
|
|
10352
|
-
output.push(`${
|
|
10366
|
+
output.push(`${quotes_1.QuoteUtils.quoteIdentifier(opFamilyName)} USING ${accessMethod}`);
|
|
10353
10367
|
}
|
|
10354
10368
|
else if (items.length === 3) {
|
|
10355
10369
|
const accessMethod = items[0].String?.sval || '';
|
|
10356
10370
|
const schemaName = items[1].String?.sval || '';
|
|
10357
10371
|
const opFamilyName = items[2].String?.sval || '';
|
|
10358
|
-
output.push(`${
|
|
10372
|
+
output.push(`${quotes_1.QuoteUtils.quoteQualifiedIdentifier(schemaName, opFamilyName)} USING ${accessMethod}`);
|
|
10359
10373
|
}
|
|
10360
10374
|
else {
|
|
10361
10375
|
output.push(this.visit(node.object, context));
|
|
@@ -10367,7 +10381,7 @@ class Deparser {
|
|
|
10367
10381
|
}
|
|
10368
10382
|
output.push('SET SCHEMA');
|
|
10369
10383
|
if (node.newschema) {
|
|
10370
|
-
output.push(
|
|
10384
|
+
output.push(quotes_1.QuoteUtils.quoteIdentifier(node.newschema));
|
|
10371
10385
|
}
|
|
10372
10386
|
return output.join(' ');
|
|
10373
10387
|
}
|
|
@@ -10436,7 +10450,7 @@ class Deparser {
|
|
|
10436
10450
|
}
|
|
10437
10451
|
if (node.servername) {
|
|
10438
10452
|
output.push('SERVER');
|
|
10439
|
-
output.push(
|
|
10453
|
+
output.push(quotes_1.QuoteUtils.quoteIdentifier(node.servername));
|
|
10440
10454
|
}
|
|
10441
10455
|
if (node.options && node.options.length > 0) {
|
|
10442
10456
|
const foreignTableContext = context.spawn('CreateForeignTableStmt');
|