pgsql-deparser 13.3.3 → 13.3.6

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/CHANGELOG.md CHANGED
@@ -3,6 +3,30 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [13.3.6](https://github.com/pyramation/pgsql-parser/compare/pgsql-deparser@13.3.5...pgsql-deparser@13.3.6) (2022-04-19)
7
+
8
+ **Note:** Version bump only for package pgsql-deparser
9
+
10
+
11
+
12
+
13
+
14
+ ## [13.3.5](https://github.com/pyramation/pgsql-parser/compare/pgsql-deparser@13.3.4...pgsql-deparser@13.3.5) (2022-04-19)
15
+
16
+ **Note:** Version bump only for package pgsql-deparser
17
+
18
+
19
+
20
+
21
+
22
+ ## [13.3.4](https://github.com/pyramation/pgsql-parser/compare/pgsql-deparser@13.3.3...pgsql-deparser@13.3.4) (2022-04-19)
23
+
24
+ **Note:** Version bump only for package pgsql-deparser
25
+
26
+
27
+
28
+
29
+
6
30
  ## [13.3.3](https://github.com/pyramation/pgsql-parser/compare/pgsql-deparser@13.3.2...pgsql-deparser@13.3.3) (2022-04-19)
7
31
 
8
32
  **Note:** Version bump only for package pgsql-deparser
package/main/deparser.js CHANGED
@@ -1412,9 +1412,18 @@ var Deparser = /*#__PURE__*/function () {
1412
1412
  key: 'IndexElem',
1413
1413
  value: function IndexElem(node) {
1414
1414
  var context = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1415
+ var output = [];
1415
1416
 
1416
1417
  if (node.name) {
1417
- return node.name;
1418
+ output.push(node.name);
1419
+
1420
+ if (node.ordering === 'SORTBY_DESC') {
1421
+ output.push('DESC');
1422
+ } else if (node.ordering === 'SORTBY_ASC') {
1423
+ output.push('ASC');
1424
+ }
1425
+
1426
+ return output.join(' ');
1418
1427
  }
1419
1428
 
1420
1429
  if (node.expr) {
@@ -2351,6 +2360,8 @@ var Deparser = /*#__PURE__*/function () {
2351
2360
  }, {
2352
2361
  key: 'CreateExtensionStmt',
2353
2362
  value: function CreateExtensionStmt(node) {
2363
+ var _this12 = this;
2364
+
2354
2365
  var output = [];
2355
2366
  output.push('CREATE EXTENSION');
2356
2367
 
@@ -2365,6 +2376,11 @@ var Deparser = /*#__PURE__*/function () {
2365
2376
  if (opt.DefElem.defname === 'cascade' && opt.DefElem.arg.Integer.ival === 1) {
2366
2377
  output.push('CASCADE');
2367
2378
  }
2379
+
2380
+ if (opt.DefElem.defname === 'schema') {
2381
+ output.push('WITH SCHEMA');
2382
+ output.push(_this12.quote(_this12.deparse(opt.DefElem.arg)));
2383
+ }
2368
2384
  });
2369
2385
  }
2370
2386
 
@@ -2572,7 +2588,7 @@ var Deparser = /*#__PURE__*/function () {
2572
2588
  }, {
2573
2589
  key: 'CreateSeqStmt',
2574
2590
  value: function CreateSeqStmt(node) {
2575
- var _this12 = this;
2591
+ var _this13 = this;
2576
2592
 
2577
2593
  var context = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2578
2594
  var output = [];
@@ -2581,7 +2597,7 @@ var Deparser = /*#__PURE__*/function () {
2581
2597
 
2582
2598
  if (node.options && node.options.length) {
2583
2599
  node.options.forEach(function (opt) {
2584
- output.push(_this12.deparse(opt, 'sequence'));
2600
+ output.push(_this13.deparse(opt, 'sequence'));
2585
2601
  });
2586
2602
  }
2587
2603
 
@@ -2590,7 +2606,7 @@ var Deparser = /*#__PURE__*/function () {
2590
2606
  }, {
2591
2607
  key: 'AlterSeqStmt',
2592
2608
  value: function AlterSeqStmt(node) {
2593
- var _this13 = this;
2609
+ var _this14 = this;
2594
2610
 
2595
2611
  var context = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2596
2612
  var output = [];
@@ -2599,7 +2615,7 @@ var Deparser = /*#__PURE__*/function () {
2599
2615
 
2600
2616
  if (node.options && node.options.length) {
2601
2617
  node.options.forEach(function (opt) {
2602
- output.push(_this13.deparse(opt, 'sequence'));
2618
+ output.push(_this14.deparse(opt, 'sequence'));
2603
2619
  });
2604
2620
  }
2605
2621
 
@@ -2619,7 +2635,7 @@ var Deparser = /*#__PURE__*/function () {
2619
2635
  }, {
2620
2636
  key: 'CreateTrigStmt',
2621
2637
  value: function CreateTrigStmt(node) {
2622
- var _this14 = this;
2638
+ var _this15 = this;
2623
2639
 
2624
2640
  var context = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2625
2641
  var output = [];
@@ -2738,7 +2754,7 @@ var Deparser = /*#__PURE__*/function () {
2738
2754
  return "'".concat(dotty.get(arg, 'String.str'), "'");
2739
2755
  }
2740
2756
 
2741
- return _this14.deparse(arg, context);
2757
+ return _this15.deparse(arg, context);
2742
2758
  }).filter(function (a) {
2743
2759
  return a;
2744
2760
  });
@@ -2897,17 +2913,17 @@ var Deparser = /*#__PURE__*/function () {
2897
2913
  var output = [];
2898
2914
 
2899
2915
  function getExclusionGroup(nde) {
2900
- var _this15 = this;
2916
+ var _this16 = this;
2901
2917
 
2902
2918
  var a = nde.exclusions.map(function (excl) {
2903
2919
  if (excl[0].IndexElem.name) {
2904
2920
  return excl[0].IndexElem.name;
2905
2921
  }
2906
2922
 
2907
- return excl[0].IndexElem.expr ? _this15.deparse(excl[0].IndexElem.expr, context) : null;
2923
+ return excl[0].IndexElem.expr ? _this16.deparse(excl[0].IndexElem.expr, context) : null;
2908
2924
  });
2909
2925
  var b = nde.exclusions.map(function (excl) {
2910
- return _this15.deparse(excl[1][0], context);
2926
+ return _this16.deparse(excl[1][0], context);
2911
2927
  });
2912
2928
  var stmts = a.map(function (_v, i) {
2913
2929
  return "".concat(a[i], " WITH ").concat(b[i]);
@@ -3125,7 +3141,7 @@ var Deparser = /*#__PURE__*/function () {
3125
3141
  }, {
3126
3142
  key: 'CreateFunctionStmt',
3127
3143
  value: function CreateFunctionStmt(node) {
3128
- var _this16 = this;
3144
+ var _this17 = this;
3129
3145
 
3130
3146
  var context = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
3131
3147
  var output = [];
@@ -3137,7 +3153,7 @@ var Deparser = /*#__PURE__*/function () {
3137
3153
 
3138
3154
  output.push('FUNCTION');
3139
3155
  output.push(node.funcname.map(function (name) {
3140
- return _this16.deparse(name, context);
3156
+ return _this17.deparse(name, context);
3141
3157
  }).join('.'));
3142
3158
  output.push('(');
3143
3159
  var parameters = [];
@@ -3174,12 +3190,12 @@ var Deparser = /*#__PURE__*/function () {
3174
3190
 
3175
3191
  switch (option.DefElem.defname) {
3176
3192
  case 'as':
3177
- value = _this16.deparse(option.DefElem.arg[0], context);
3193
+ value = _this17.deparse(option.DefElem.arg[0], context);
3178
3194
  output.push("AS $EOFCODE$".concat(value, "$EOFCODE$"));
3179
3195
  break;
3180
3196
 
3181
3197
  case 'language':
3182
- value = _this16.deparse(option.DefElem.arg, context);
3198
+ value = _this17.deparse(option.DefElem.arg, context);
3183
3199
  output.push('LANGUAGE');
3184
3200
  output.push(value);
3185
3201
  break;
@@ -3226,11 +3242,11 @@ var Deparser = /*#__PURE__*/function () {
3226
3242
  break;
3227
3243
 
3228
3244
  case 'set':
3229
- output.push(_this16.deparse(option, context));
3245
+ output.push(_this17.deparse(option, context));
3230
3246
  break;
3231
3247
 
3232
3248
  case 'volatility':
3233
- value = _this16.deparse(option.DefElem.arg, context);
3249
+ value = _this17.deparse(option.DefElem.arg, context);
3234
3250
  output.push(value.toUpperCase());
3235
3251
  break;
3236
3252
 
@@ -3427,7 +3443,7 @@ var Deparser = /*#__PURE__*/function () {
3427
3443
  }, {
3428
3444
  key: 'CreateRoleStmt',
3429
3445
  value: function CreateRoleStmt(node) {
3430
- var _this17 = this;
3446
+ var _this18 = this;
3431
3447
 
3432
3448
  var context = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
3433
3449
  var output = [];
@@ -3488,12 +3504,12 @@ var Deparser = /*#__PURE__*/function () {
3488
3504
 
3489
3505
  case 'adminmembers':
3490
3506
  output.push('ADMIN');
3491
- output.push(_this17.list(node.options[i].DefElem.arg, ', ', '', context));
3507
+ output.push(_this18.list(node.options[i].DefElem.arg, ', ', '', context));
3492
3508
  break;
3493
3509
 
3494
3510
  case 'rolemembers':
3495
3511
  output.push('USER');
3496
- output.push(_this17.list(node.options[i].DefElem.arg, ', ', '', context));
3512
+ output.push(_this18.list(node.options[i].DefElem.arg, ', ', '', context));
3497
3513
  break;
3498
3514
 
3499
3515
  case 'createdb':
@@ -3536,7 +3552,7 @@ var Deparser = /*#__PURE__*/function () {
3536
3552
  }, {
3537
3553
  key: 'TransactionStmt',
3538
3554
  value: function TransactionStmt(node) {
3539
- var _this18 = this;
3555
+ var _this19 = this;
3540
3556
 
3541
3557
  var context = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
3542
3558
  var output = [];
@@ -3548,7 +3564,7 @@ var Deparser = /*#__PURE__*/function () {
3548
3564
  var index = opts.indexOf('transaction_read_only');
3549
3565
  var obj = nodeOpts.options[index];
3550
3566
  var set = false;
3551
- var flag = Number(_this18.deparse(dotty.get(obj, 'DefElem.arg'), context));
3567
+ var flag = Number(_this19.deparse(dotty.get(obj, 'DefElem.arg'), context));
3552
3568
 
3553
3569
  if (flag > 0) {
3554
3570
  set = true;
@@ -3566,7 +3582,7 @@ var Deparser = /*#__PURE__*/function () {
3566
3582
 
3567
3583
  var _obj = nodeOpts.options[_index];
3568
3584
 
3569
- var lopts = _this18.deparse(dotty.get(_obj, 'DefElem.arg'), context).replace(/['"]+/g, '');
3585
+ var lopts = _this19.deparse(dotty.get(_obj, 'DefElem.arg'), context).replace(/['"]+/g, '');
3570
3586
 
3571
3587
  return "BEGIN TRANSACTION ISOLATION LEVEL ".concat(lopts.toUpperCase());
3572
3588
  }
@@ -3581,7 +3597,7 @@ var Deparser = /*#__PURE__*/function () {
3581
3597
  var index = opts.indexOf('transaction_read_only');
3582
3598
  var obj = nodeOpts.options[index];
3583
3599
  var set = false;
3584
- var flag = Number(_this18.deparse(dotty.get(obj, 'DefElem.arg'), context));
3600
+ var flag = Number(_this19.deparse(dotty.get(obj, 'DefElem.arg'), context));
3585
3601
 
3586
3602
  if (flag > 0) {
3587
3603
  set = true;
@@ -3685,7 +3701,7 @@ var Deparser = /*#__PURE__*/function () {
3685
3701
  }, {
3686
3702
  key: 'ObjectWithArgs',
3687
3703
  value: function ObjectWithArgs(node) {
3688
- var _this19 = this;
3704
+ var _this20 = this;
3689
3705
 
3690
3706
  var context = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
3691
3707
  var output = [];
@@ -3703,7 +3719,7 @@ var Deparser = /*#__PURE__*/function () {
3703
3719
  return 'NONE';
3704
3720
  }
3705
3721
 
3706
- return _this19.deparse(arg, context);
3722
+ return _this20.deparse(arg, context);
3707
3723
  }).join(','));
3708
3724
  output.push(')');
3709
3725
  }
@@ -3780,7 +3796,7 @@ var Deparser = /*#__PURE__*/function () {
3780
3796
  }, {
3781
3797
  key: 'TypeName',
3782
3798
  value: function TypeName(node) {
3783
- var _this20 = this;
3799
+ var _this21 = this;
3784
3800
 
3785
3801
  var context = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
3786
3802
 
@@ -3798,7 +3814,7 @@ var Deparser = /*#__PURE__*/function () {
3798
3814
 
3799
3815
  if (node.typmods != null) {
3800
3816
  args = node.typmods.map(function (item) {
3801
- return _this20.deparse(item, context);
3817
+ return _this21.deparse(item, context);
3802
3818
  });
3803
3819
  }
3804
3820
 
@@ -3825,7 +3841,7 @@ var Deparser = /*#__PURE__*/function () {
3825
3841
  }, {
3826
3842
  key: 'WindowDef',
3827
3843
  value: function WindowDef(node) {
3828
- var _this21 = this;
3844
+ var _this22 = this;
3829
3845
 
3830
3846
  var context = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
3831
3847
  var output = [];
@@ -3849,7 +3865,7 @@ var Deparser = /*#__PURE__*/function () {
3849
3865
  if (node.partitionClause) {
3850
3866
  var partition = ['PARTITION BY'];
3851
3867
  var clause = node.partitionClause.map(function (item) {
3852
- return _this21.deparse(item, context);
3868
+ return _this22.deparse(item, context);
3853
3869
  });
3854
3870
  partition.push(clause.join(', '));
3855
3871
  windowParts.push(partition.join(' '));
@@ -3859,7 +3875,7 @@ var Deparser = /*#__PURE__*/function () {
3859
3875
  if (node.orderClause) {
3860
3876
  windowParts.push('ORDER BY');
3861
3877
  var orders = node.orderClause.map(function (item) {
3862
- return _this21.deparse(item);
3878
+ return _this22.deparse(item);
3863
3879
  });
3864
3880
  windowParts.push(orders.join(', '));
3865
3881
  useParens = true;
@@ -3907,6 +3923,23 @@ var Deparser = /*#__PURE__*/function () {
3907
3923
  return output.join(' ');
3908
3924
  }
3909
3925
  }, {
3926
+ key: 'CallStmt',
3927
+ value: function CallStmt(node) {
3928
+ var context = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
3929
+ var output = ['CALL'];
3930
+ output.push(this.deparse(node.funccall.funcname[0]));
3931
+
3932
+ if (node.funccall.args && node.funccall.args.length) {
3933
+ // we have arguments
3934
+ output.push('(' + this.list(node.funccall.args, ', ', '', context) + ')');
3935
+ } else {
3936
+ // just close parens
3937
+ output.push('()');
3938
+ }
3939
+
3940
+ return output.join(' ');
3941
+ }
3942
+ }, {
3910
3943
  key: "deparseFrameOptions",
3911
3944
  value: function deparseFrameOptions(options, refName, startOffset, endOffset) {
3912
3945
  // https://github.com/pganalyze/libpg_query/blob/442b1748d06364ecd3779bc558899176c02efaf0/src/postgres/include/nodes/parsenodes.h#L505-L522
@@ -4049,7 +4082,7 @@ var Deparser = /*#__PURE__*/function () {
4049
4082
  }, {
4050
4083
  key: "deparseInterval",
4051
4084
  value: function deparseInterval(node) {
4052
- var _this22 = this;
4085
+ var _this23 = this;
4053
4086
 
4054
4087
  var type = ['interval'];
4055
4088
 
@@ -4059,7 +4092,7 @@ var Deparser = /*#__PURE__*/function () {
4059
4092
 
4060
4093
  if (node.typmods) {
4061
4094
  var typmods = node.typmods.map(function (item) {
4062
- return _this22.deparse(item);
4095
+ return _this23.deparse(item);
4063
4096
  });
4064
4097
  var intervals = this.interval(typmods[0]); // SELECT interval(0) '1 day 01:23:45.6789'
4065
4098
 
@@ -1275,8 +1275,18 @@ export default class Deparser {
1275
1275
  }
1276
1276
 
1277
1277
  ['IndexElem'](node, context = {}) {
1278
+ const output = [];
1279
+
1278
1280
  if (node.name) {
1279
- return node.name;
1281
+ output.push(node.name);
1282
+
1283
+ if (node.ordering === 'SORTBY_DESC') {
1284
+ output.push('DESC');
1285
+ } else if (node.ordering === 'SORTBY_ASC') {
1286
+ output.push('ASC');
1287
+ }
1288
+
1289
+ return output.join(' ');
1280
1290
  }
1281
1291
 
1282
1292
  if (node.expr) {
@@ -2143,6 +2153,11 @@ export default class Deparser {
2143
2153
  if (opt.DefElem.defname === 'cascade' && opt.DefElem.arg.Integer.ival === 1) {
2144
2154
  output.push('CASCADE');
2145
2155
  }
2156
+
2157
+ if (opt.DefElem.defname === 'schema') {
2158
+ output.push('WITH SCHEMA');
2159
+ output.push(this.quote(this.deparse(opt.DefElem.arg)));
2160
+ }
2146
2161
  });
2147
2162
  }
2148
2163
 
@@ -3582,6 +3597,21 @@ export default class Deparser {
3582
3597
  return output.join(' ');
3583
3598
  }
3584
3599
 
3600
+ ['CallStmt'](node, context = {}) {
3601
+ const output = ['CALL'];
3602
+ output.push(this.deparse(node.funccall.funcname[0]));
3603
+
3604
+ if (node.funccall.args && node.funccall.args.length) {
3605
+ // we have arguments
3606
+ output.push('(' + this.list(node.funccall.args, ', ', '', context) + ')');
3607
+ } else {
3608
+ // just close parens
3609
+ output.push('()');
3610
+ }
3611
+
3612
+ return output.join(' ');
3613
+ }
3614
+
3585
3615
  deparseFrameOptions(options, refName, startOffset, endOffset) {
3586
3616
  // https://github.com/pganalyze/libpg_query/blob/442b1748d06364ecd3779bc558899176c02efaf0/src/postgres/include/nodes/parsenodes.h#L505-L522
3587
3617
  const FRAMEOPTION_NONDEFAULT = 0x00001;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pgsql-deparser",
3
- "version": "13.3.3",
3
+ "version": "13.3.6",
4
4
  "description": "PostgreSQL AST Deparser",
5
5
  "author": "Dan Lynch <pyramation@gmail.com>",
6
6
  "homepage": "https://github.com/pyramation/pgsql-parser",
@@ -65,7 +65,7 @@
65
65
  "eslint-plugin-prettier": "^3.1.2",
66
66
  "glob": "7.1.6",
67
67
  "jest": "^25.1.0",
68
- "pgsql-parser": "^13.3.3",
68
+ "pgsql-parser": "^13.3.6",
69
69
  "prettier": "^2.1.2",
70
70
  "regenerator-runtime": "^0.13.2"
71
71
  },
@@ -75,5 +75,5 @@
75
75
  "lodash": "^4.17.20",
76
76
  "pgsql-enums": "^13.1.2"
77
77
  },
78
- "gitHead": "33e5e0562136c7b84b476594298fbadc8cae957b"
78
+ "gitHead": "9e241dc39d3469afe7908cd7e2e9f847efa43f6f"
79
79
  }