pgsql-deparser 17.7.0 → 17.7.2
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 +37 -7
- package/esm/deparser.js +37 -7
- package/package.json +2 -2
package/deparser.js
CHANGED
|
@@ -381,18 +381,38 @@ class Deparser {
|
|
|
381
381
|
'ALL',
|
|
382
382
|
this.formatter.parens(this.visit(rexpr, context))
|
|
383
383
|
]);
|
|
384
|
-
case 'AEXPR_DISTINCT':
|
|
384
|
+
case 'AEXPR_DISTINCT': {
|
|
385
|
+
let leftExpr = this.visit(lexpr, context);
|
|
386
|
+
let rightExpr = this.visit(rexpr, context);
|
|
387
|
+
// Add parentheses for complex expressions
|
|
388
|
+
if (lexpr && this.isComplexExpression(lexpr)) {
|
|
389
|
+
leftExpr = this.formatter.parens(leftExpr);
|
|
390
|
+
}
|
|
391
|
+
if (rexpr && this.isComplexExpression(rexpr)) {
|
|
392
|
+
rightExpr = this.formatter.parens(rightExpr);
|
|
393
|
+
}
|
|
385
394
|
return this.formatter.format([
|
|
386
|
-
|
|
395
|
+
leftExpr,
|
|
387
396
|
'IS DISTINCT FROM',
|
|
388
|
-
|
|
397
|
+
rightExpr
|
|
389
398
|
]);
|
|
390
|
-
|
|
399
|
+
}
|
|
400
|
+
case 'AEXPR_NOT_DISTINCT': {
|
|
401
|
+
let leftExpr = this.visit(lexpr, context);
|
|
402
|
+
let rightExpr = this.visit(rexpr, context);
|
|
403
|
+
// Add parentheses for complex expressions
|
|
404
|
+
if (lexpr && this.isComplexExpression(lexpr)) {
|
|
405
|
+
leftExpr = this.formatter.parens(leftExpr);
|
|
406
|
+
}
|
|
407
|
+
if (rexpr && this.isComplexExpression(rexpr)) {
|
|
408
|
+
rightExpr = this.formatter.parens(rightExpr);
|
|
409
|
+
}
|
|
391
410
|
return this.formatter.format([
|
|
392
|
-
|
|
411
|
+
leftExpr,
|
|
393
412
|
'IS NOT DISTINCT FROM',
|
|
394
|
-
|
|
413
|
+
rightExpr
|
|
395
414
|
]);
|
|
415
|
+
}
|
|
396
416
|
case 'AEXPR_NULLIF':
|
|
397
417
|
return this.formatter.format([
|
|
398
418
|
'NULLIF',
|
|
@@ -1459,7 +1479,14 @@ class Deparser {
|
|
|
1459
1479
|
output.push('ONLY');
|
|
1460
1480
|
}
|
|
1461
1481
|
let tableName = '';
|
|
1462
|
-
if (node.
|
|
1482
|
+
if (node.catalogname) {
|
|
1483
|
+
tableName = quote_utils_1.QuoteUtils.quote(node.catalogname);
|
|
1484
|
+
if (node.schemaname) {
|
|
1485
|
+
tableName += '.' + quote_utils_1.QuoteUtils.quote(node.schemaname);
|
|
1486
|
+
}
|
|
1487
|
+
tableName += '.' + quote_utils_1.QuoteUtils.quote(node.relname);
|
|
1488
|
+
}
|
|
1489
|
+
else if (node.schemaname) {
|
|
1463
1490
|
tableName = quote_utils_1.QuoteUtils.quote(node.schemaname) + '.' + quote_utils_1.QuoteUtils.quote(node.relname);
|
|
1464
1491
|
}
|
|
1465
1492
|
else {
|
|
@@ -2155,6 +2182,9 @@ class Deparser {
|
|
|
2155
2182
|
break;
|
|
2156
2183
|
case 'CONSTR_UNIQUE':
|
|
2157
2184
|
output.push('UNIQUE');
|
|
2185
|
+
if (node.nulls_not_distinct) {
|
|
2186
|
+
output.push('NULLS NOT DISTINCT');
|
|
2187
|
+
}
|
|
2158
2188
|
if (node.keys && node.keys.length > 0) {
|
|
2159
2189
|
const keyList = list_utils_1.ListUtils.unwrapList(node.keys)
|
|
2160
2190
|
.map(key => this.visit(key, context))
|
package/esm/deparser.js
CHANGED
|
@@ -378,18 +378,38 @@ export class Deparser {
|
|
|
378
378
|
'ALL',
|
|
379
379
|
this.formatter.parens(this.visit(rexpr, context))
|
|
380
380
|
]);
|
|
381
|
-
case 'AEXPR_DISTINCT':
|
|
381
|
+
case 'AEXPR_DISTINCT': {
|
|
382
|
+
let leftExpr = this.visit(lexpr, context);
|
|
383
|
+
let rightExpr = this.visit(rexpr, context);
|
|
384
|
+
// Add parentheses for complex expressions
|
|
385
|
+
if (lexpr && this.isComplexExpression(lexpr)) {
|
|
386
|
+
leftExpr = this.formatter.parens(leftExpr);
|
|
387
|
+
}
|
|
388
|
+
if (rexpr && this.isComplexExpression(rexpr)) {
|
|
389
|
+
rightExpr = this.formatter.parens(rightExpr);
|
|
390
|
+
}
|
|
382
391
|
return this.formatter.format([
|
|
383
|
-
|
|
392
|
+
leftExpr,
|
|
384
393
|
'IS DISTINCT FROM',
|
|
385
|
-
|
|
394
|
+
rightExpr
|
|
386
395
|
]);
|
|
387
|
-
|
|
396
|
+
}
|
|
397
|
+
case 'AEXPR_NOT_DISTINCT': {
|
|
398
|
+
let leftExpr = this.visit(lexpr, context);
|
|
399
|
+
let rightExpr = this.visit(rexpr, context);
|
|
400
|
+
// Add parentheses for complex expressions
|
|
401
|
+
if (lexpr && this.isComplexExpression(lexpr)) {
|
|
402
|
+
leftExpr = this.formatter.parens(leftExpr);
|
|
403
|
+
}
|
|
404
|
+
if (rexpr && this.isComplexExpression(rexpr)) {
|
|
405
|
+
rightExpr = this.formatter.parens(rightExpr);
|
|
406
|
+
}
|
|
388
407
|
return this.formatter.format([
|
|
389
|
-
|
|
408
|
+
leftExpr,
|
|
390
409
|
'IS NOT DISTINCT FROM',
|
|
391
|
-
|
|
410
|
+
rightExpr
|
|
392
411
|
]);
|
|
412
|
+
}
|
|
393
413
|
case 'AEXPR_NULLIF':
|
|
394
414
|
return this.formatter.format([
|
|
395
415
|
'NULLIF',
|
|
@@ -1456,7 +1476,14 @@ export class Deparser {
|
|
|
1456
1476
|
output.push('ONLY');
|
|
1457
1477
|
}
|
|
1458
1478
|
let tableName = '';
|
|
1459
|
-
if (node.
|
|
1479
|
+
if (node.catalogname) {
|
|
1480
|
+
tableName = QuoteUtils.quote(node.catalogname);
|
|
1481
|
+
if (node.schemaname) {
|
|
1482
|
+
tableName += '.' + QuoteUtils.quote(node.schemaname);
|
|
1483
|
+
}
|
|
1484
|
+
tableName += '.' + QuoteUtils.quote(node.relname);
|
|
1485
|
+
}
|
|
1486
|
+
else if (node.schemaname) {
|
|
1460
1487
|
tableName = QuoteUtils.quote(node.schemaname) + '.' + QuoteUtils.quote(node.relname);
|
|
1461
1488
|
}
|
|
1462
1489
|
else {
|
|
@@ -2152,6 +2179,9 @@ export class Deparser {
|
|
|
2152
2179
|
break;
|
|
2153
2180
|
case 'CONSTR_UNIQUE':
|
|
2154
2181
|
output.push('UNIQUE');
|
|
2182
|
+
if (node.nulls_not_distinct) {
|
|
2183
|
+
output.push('NULLS NOT DISTINCT');
|
|
2184
|
+
}
|
|
2155
2185
|
if (node.keys && node.keys.length > 0) {
|
|
2156
2186
|
const keyList = ListUtils.unwrapList(node.keys)
|
|
2157
2187
|
.map(key => this.visit(key, context))
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pgsql-deparser",
|
|
3
|
-
"version": "17.7.
|
|
3
|
+
"version": "17.7.2",
|
|
4
4
|
"author": "Dan Lynch <pyramation@gmail.com>",
|
|
5
5
|
"description": "PostgreSQL AST Deparser",
|
|
6
6
|
"main": "index.js",
|
|
@@ -51,5 +51,5 @@
|
|
|
51
51
|
"dependencies": {
|
|
52
52
|
"@pgsql/types": "^17.6.1"
|
|
53
53
|
},
|
|
54
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "e191d2f1ca9257a70f7cb052552f3546691d2ef6"
|
|
55
55
|
}
|