pgsql-deparser 17.18.0 → 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 +24 -10
- package/esm/deparser.js +24 -10
- package/package.json +2 -2
package/deparser.js
CHANGED
|
@@ -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)) {
|
|
@@ -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
|
}
|
|
@@ -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) {
|
package/esm/deparser.js
CHANGED
|
@@ -505,9 +505,7 @@ export class Deparser {
|
|
|
505
505
|
output.push('VALUES');
|
|
506
506
|
const lists = ListUtils.unwrapList(node.valuesLists).map(list => {
|
|
507
507
|
const values = ListUtils.unwrapList(list).map(val => this.visit(val, context));
|
|
508
|
-
|
|
509
|
-
const indentedValues = values.map(val => context.indent(val));
|
|
510
|
-
return '(\n' + indentedValues.join(',\n') + '\n)';
|
|
508
|
+
return context.parens(values.join(', '));
|
|
511
509
|
});
|
|
512
510
|
const indentedTuples = lists.map(tuple => {
|
|
513
511
|
if (this.containsMultilineStringLiteral(tuple)) {
|
|
@@ -1761,7 +1759,7 @@ export class Deparser {
|
|
|
1761
1759
|
}
|
|
1762
1760
|
return output.join(' ');
|
|
1763
1761
|
}
|
|
1764
|
-
let result = mods(typeName, args);
|
|
1762
|
+
let result = mods(QuoteUtils.quoteIdentifierTypeName(typeName), args);
|
|
1765
1763
|
if (node.arrayBounds && node.arrayBounds.length > 0) {
|
|
1766
1764
|
result += formatArrayBounds(node.arrayBounds);
|
|
1767
1765
|
}
|
|
@@ -2873,6 +2871,10 @@ export class Deparser {
|
|
|
2873
2871
|
});
|
|
2874
2872
|
output.push(`(${exclusionElements.join(', ')})`);
|
|
2875
2873
|
}
|
|
2874
|
+
if (node.where_clause) {
|
|
2875
|
+
output.push('WHERE');
|
|
2876
|
+
output.push(context.parens(this.visit(node.where_clause, context)));
|
|
2877
|
+
}
|
|
2876
2878
|
break;
|
|
2877
2879
|
}
|
|
2878
2880
|
// Handle deferrable constraints for all constraint types that support it
|
|
@@ -3006,6 +3008,8 @@ export class Deparser {
|
|
|
3006
3008
|
if (!node.frameOptions)
|
|
3007
3009
|
return null;
|
|
3008
3010
|
const frameOptions = node.frameOptions;
|
|
3011
|
+
const EXCLUDE_MASK = 0x8000 | 0x10000 | 0x20000;
|
|
3012
|
+
const baseFrameOptions = frameOptions & ~EXCLUDE_MASK;
|
|
3009
3013
|
const frameParts = [];
|
|
3010
3014
|
if (frameOptions & 0x01) { // FRAMEOPTION_NONDEFAULT
|
|
3011
3015
|
if (frameOptions & 0x02) { // FRAMEOPTION_RANGE
|
|
@@ -3022,31 +3026,31 @@ export class Deparser {
|
|
|
3022
3026
|
return null;
|
|
3023
3027
|
const boundsParts = [];
|
|
3024
3028
|
// Handle specific frameOptions values that have known mappings
|
|
3025
|
-
if (
|
|
3029
|
+
if (baseFrameOptions === 789) {
|
|
3026
3030
|
boundsParts.push('CURRENT ROW');
|
|
3027
3031
|
boundsParts.push('AND UNBOUNDED FOLLOWING');
|
|
3028
3032
|
}
|
|
3029
|
-
else if (
|
|
3033
|
+
else if (baseFrameOptions === 1077) {
|
|
3030
3034
|
boundsParts.push('UNBOUNDED PRECEDING');
|
|
3031
3035
|
boundsParts.push('AND CURRENT ROW');
|
|
3032
3036
|
}
|
|
3033
|
-
else if (
|
|
3037
|
+
else if (baseFrameOptions === 18453) {
|
|
3034
3038
|
if (node.startOffset && node.endOffset) {
|
|
3035
3039
|
boundsParts.push(`${this.visit(node.startOffset, context)} PRECEDING`);
|
|
3036
3040
|
boundsParts.push(`AND ${this.visit(node.endOffset, context)} FOLLOWING`);
|
|
3037
3041
|
}
|
|
3038
3042
|
}
|
|
3039
|
-
else if (
|
|
3043
|
+
else if (baseFrameOptions === 1557) {
|
|
3040
3044
|
boundsParts.push('CURRENT ROW');
|
|
3041
3045
|
boundsParts.push('AND CURRENT ROW');
|
|
3042
3046
|
}
|
|
3043
|
-
else if (
|
|
3047
|
+
else if (baseFrameOptions === 16917) {
|
|
3044
3048
|
boundsParts.push('CURRENT ROW');
|
|
3045
3049
|
if (node.endOffset) {
|
|
3046
3050
|
boundsParts.push(`AND ${this.visit(node.endOffset, context)} FOLLOWING`);
|
|
3047
3051
|
}
|
|
3048
3052
|
}
|
|
3049
|
-
else if (
|
|
3053
|
+
else if (baseFrameOptions === 1058) {
|
|
3050
3054
|
return null;
|
|
3051
3055
|
}
|
|
3052
3056
|
else {
|
|
@@ -3100,6 +3104,16 @@ export class Deparser {
|
|
|
3100
3104
|
frameParts.push('BETWEEN');
|
|
3101
3105
|
frameParts.push(boundsParts.join(' '));
|
|
3102
3106
|
}
|
|
3107
|
+
// EXCLUDE clause
|
|
3108
|
+
if (frameOptions & 0x8000) { // FRAMEOPTION_EXCLUDE_CURRENT_ROW
|
|
3109
|
+
frameParts.push('EXCLUDE CURRENT ROW');
|
|
3110
|
+
}
|
|
3111
|
+
else if (frameOptions & 0x10000) { // FRAMEOPTION_EXCLUDE_GROUP
|
|
3112
|
+
frameParts.push('EXCLUDE GROUP');
|
|
3113
|
+
}
|
|
3114
|
+
else if (frameOptions & 0x20000) { // FRAMEOPTION_EXCLUDE_TIES
|
|
3115
|
+
frameParts.push('EXCLUDE TIES');
|
|
3116
|
+
}
|
|
3103
3117
|
return frameParts.join(' ');
|
|
3104
3118
|
}
|
|
3105
3119
|
SortBy(node, context) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pgsql-deparser",
|
|
3
|
-
"version": "17.18.
|
|
3
|
+
"version": "17.18.1",
|
|
4
4
|
"author": "Constructive <developers@constructive.io>",
|
|
5
5
|
"description": "PostgreSQL AST Deparser",
|
|
6
6
|
"main": "index.js",
|
|
@@ -60,5 +60,5 @@
|
|
|
60
60
|
"@pgsql/quotes": "17.1.0",
|
|
61
61
|
"@pgsql/types": "^17.6.2"
|
|
62
62
|
},
|
|
63
|
-
"gitHead": "
|
|
63
|
+
"gitHead": "58ddefe11a5d002db6645fa7bc2f284123d48470"
|
|
64
64
|
}
|