pgsql-deparser 13.3.2 → 13.3.5

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.5](https://github.com/pyramation/pgsql-parser/compare/pgsql-deparser@13.3.4...pgsql-deparser@13.3.5) (2022-04-19)
7
+
8
+ **Note:** Version bump only for package pgsql-deparser
9
+
10
+
11
+
12
+
13
+
14
+ ## [13.3.4](https://github.com/pyramation/pgsql-parser/compare/pgsql-deparser@13.3.3...pgsql-deparser@13.3.4) (2022-04-19)
15
+
16
+ **Note:** Version bump only for package pgsql-deparser
17
+
18
+
19
+
20
+
21
+
22
+ ## [13.3.3](https://github.com/pyramation/pgsql-parser/compare/pgsql-deparser@13.3.2...pgsql-deparser@13.3.3) (2022-04-19)
23
+
24
+ **Note:** Version bump only for package pgsql-deparser
25
+
26
+
27
+
28
+
29
+
6
30
  ## [13.3.2](https://github.com/pyramation/pgsql-parser/compare/pgsql-deparser@13.3.1...pgsql-deparser@13.3.2) (2022-04-19)
7
31
 
8
32
  **Note:** Version bump only for package pgsql-deparser
package/main/deparser.js CHANGED
@@ -2351,6 +2351,8 @@ var Deparser = /*#__PURE__*/function () {
2351
2351
  }, {
2352
2352
  key: 'CreateExtensionStmt',
2353
2353
  value: function CreateExtensionStmt(node) {
2354
+ var _this12 = this;
2355
+
2354
2356
  var output = [];
2355
2357
  output.push('CREATE EXTENSION');
2356
2358
 
@@ -2365,6 +2367,11 @@ var Deparser = /*#__PURE__*/function () {
2365
2367
  if (opt.DefElem.defname === 'cascade' && opt.DefElem.arg.Integer.ival === 1) {
2366
2368
  output.push('CASCADE');
2367
2369
  }
2370
+
2371
+ if (opt.DefElem.defname === 'schema') {
2372
+ output.push('WITH SCHEMA');
2373
+ output.push(_this12.quote(_this12.deparse(opt.DefElem.arg)));
2374
+ }
2368
2375
  });
2369
2376
  }
2370
2377
 
@@ -2572,7 +2579,7 @@ var Deparser = /*#__PURE__*/function () {
2572
2579
  }, {
2573
2580
  key: 'CreateSeqStmt',
2574
2581
  value: function CreateSeqStmt(node) {
2575
- var _this12 = this;
2582
+ var _this13 = this;
2576
2583
 
2577
2584
  var context = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2578
2585
  var output = [];
@@ -2581,7 +2588,7 @@ var Deparser = /*#__PURE__*/function () {
2581
2588
 
2582
2589
  if (node.options && node.options.length) {
2583
2590
  node.options.forEach(function (opt) {
2584
- output.push(_this12.deparse(opt, 'sequence'));
2591
+ output.push(_this13.deparse(opt, 'sequence'));
2585
2592
  });
2586
2593
  }
2587
2594
 
@@ -2590,7 +2597,7 @@ var Deparser = /*#__PURE__*/function () {
2590
2597
  }, {
2591
2598
  key: 'AlterSeqStmt',
2592
2599
  value: function AlterSeqStmt(node) {
2593
- var _this13 = this;
2600
+ var _this14 = this;
2594
2601
 
2595
2602
  var context = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2596
2603
  var output = [];
@@ -2599,7 +2606,7 @@ var Deparser = /*#__PURE__*/function () {
2599
2606
 
2600
2607
  if (node.options && node.options.length) {
2601
2608
  node.options.forEach(function (opt) {
2602
- output.push(_this13.deparse(opt, 'sequence'));
2609
+ output.push(_this14.deparse(opt, 'sequence'));
2603
2610
  });
2604
2611
  }
2605
2612
 
@@ -2619,7 +2626,7 @@ var Deparser = /*#__PURE__*/function () {
2619
2626
  }, {
2620
2627
  key: 'CreateTrigStmt',
2621
2628
  value: function CreateTrigStmt(node) {
2622
- var _this14 = this;
2629
+ var _this15 = this;
2623
2630
 
2624
2631
  var context = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2625
2632
  var output = [];
@@ -2738,7 +2745,7 @@ var Deparser = /*#__PURE__*/function () {
2738
2745
  return "'".concat(dotty.get(arg, 'String.str'), "'");
2739
2746
  }
2740
2747
 
2741
- return _this14.deparse(arg, context);
2748
+ return _this15.deparse(arg, context);
2742
2749
  }).filter(function (a) {
2743
2750
  return a;
2744
2751
  });
@@ -2897,17 +2904,17 @@ var Deparser = /*#__PURE__*/function () {
2897
2904
  var output = [];
2898
2905
 
2899
2906
  function getExclusionGroup(nde) {
2900
- var _this15 = this;
2907
+ var _this16 = this;
2901
2908
 
2902
2909
  var a = nde.exclusions.map(function (excl) {
2903
2910
  if (excl[0].IndexElem.name) {
2904
2911
  return excl[0].IndexElem.name;
2905
2912
  }
2906
2913
 
2907
- return excl[0].IndexElem.expr ? _this15.deparse(excl[0].IndexElem.expr, context) : null;
2914
+ return excl[0].IndexElem.expr ? _this16.deparse(excl[0].IndexElem.expr, context) : null;
2908
2915
  });
2909
2916
  var b = nde.exclusions.map(function (excl) {
2910
- return _this15.deparse(excl[1][0], context);
2917
+ return _this16.deparse(excl[1][0], context);
2911
2918
  });
2912
2919
  var stmts = a.map(function (_v, i) {
2913
2920
  return "".concat(a[i], " WITH ").concat(b[i]);
@@ -3125,7 +3132,7 @@ var Deparser = /*#__PURE__*/function () {
3125
3132
  }, {
3126
3133
  key: 'CreateFunctionStmt',
3127
3134
  value: function CreateFunctionStmt(node) {
3128
- var _this16 = this;
3135
+ var _this17 = this;
3129
3136
 
3130
3137
  var context = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
3131
3138
  var output = [];
@@ -3137,7 +3144,7 @@ var Deparser = /*#__PURE__*/function () {
3137
3144
 
3138
3145
  output.push('FUNCTION');
3139
3146
  output.push(node.funcname.map(function (name) {
3140
- return _this16.deparse(name, context);
3147
+ return _this17.deparse(name, context);
3141
3148
  }).join('.'));
3142
3149
  output.push('(');
3143
3150
  var parameters = [];
@@ -3174,12 +3181,12 @@ var Deparser = /*#__PURE__*/function () {
3174
3181
 
3175
3182
  switch (option.DefElem.defname) {
3176
3183
  case 'as':
3177
- value = _this16.deparse(option.DefElem.arg[0], context);
3184
+ value = _this17.deparse(option.DefElem.arg[0], context);
3178
3185
  output.push("AS $EOFCODE$".concat(value, "$EOFCODE$"));
3179
3186
  break;
3180
3187
 
3181
3188
  case 'language':
3182
- value = _this16.deparse(option.DefElem.arg, context);
3189
+ value = _this17.deparse(option.DefElem.arg, context);
3183
3190
  output.push('LANGUAGE');
3184
3191
  output.push(value);
3185
3192
  break;
@@ -3226,11 +3233,11 @@ var Deparser = /*#__PURE__*/function () {
3226
3233
  break;
3227
3234
 
3228
3235
  case 'set':
3229
- output.push(_this16.deparse(option, context));
3236
+ output.push(_this17.deparse(option, context));
3230
3237
  break;
3231
3238
 
3232
3239
  case 'volatility':
3233
- value = _this16.deparse(option.DefElem.arg, context);
3240
+ value = _this17.deparse(option.DefElem.arg, context);
3234
3241
  output.push(value.toUpperCase());
3235
3242
  break;
3236
3243
 
@@ -3427,7 +3434,7 @@ var Deparser = /*#__PURE__*/function () {
3427
3434
  }, {
3428
3435
  key: 'CreateRoleStmt',
3429
3436
  value: function CreateRoleStmt(node) {
3430
- var _this17 = this;
3437
+ var _this18 = this;
3431
3438
 
3432
3439
  var context = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
3433
3440
  var output = [];
@@ -3488,12 +3495,12 @@ var Deparser = /*#__PURE__*/function () {
3488
3495
 
3489
3496
  case 'adminmembers':
3490
3497
  output.push('ADMIN');
3491
- output.push(_this17.list(node.options[i].DefElem.arg, ', ', '', context));
3498
+ output.push(_this18.list(node.options[i].DefElem.arg, ', ', '', context));
3492
3499
  break;
3493
3500
 
3494
3501
  case 'rolemembers':
3495
3502
  output.push('USER');
3496
- output.push(_this17.list(node.options[i].DefElem.arg, ', ', '', context));
3503
+ output.push(_this18.list(node.options[i].DefElem.arg, ', ', '', context));
3497
3504
  break;
3498
3505
 
3499
3506
  case 'createdb':
@@ -3536,7 +3543,7 @@ var Deparser = /*#__PURE__*/function () {
3536
3543
  }, {
3537
3544
  key: 'TransactionStmt',
3538
3545
  value: function TransactionStmt(node) {
3539
- var _this18 = this;
3546
+ var _this19 = this;
3540
3547
 
3541
3548
  var context = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
3542
3549
  var output = [];
@@ -3548,7 +3555,7 @@ var Deparser = /*#__PURE__*/function () {
3548
3555
  var index = opts.indexOf('transaction_read_only');
3549
3556
  var obj = nodeOpts.options[index];
3550
3557
  var set = false;
3551
- var flag = Number(_this18.deparse(dotty.get(obj, 'DefElem.arg'), context));
3558
+ var flag = Number(_this19.deparse(dotty.get(obj, 'DefElem.arg'), context));
3552
3559
 
3553
3560
  if (flag > 0) {
3554
3561
  set = true;
@@ -3566,7 +3573,7 @@ var Deparser = /*#__PURE__*/function () {
3566
3573
 
3567
3574
  var _obj = nodeOpts.options[_index];
3568
3575
 
3569
- var lopts = _this18.deparse(dotty.get(_obj, 'DefElem.arg'), context).replace(/['"]+/g, '');
3576
+ var lopts = _this19.deparse(dotty.get(_obj, 'DefElem.arg'), context).replace(/['"]+/g, '');
3570
3577
 
3571
3578
  return "BEGIN TRANSACTION ISOLATION LEVEL ".concat(lopts.toUpperCase());
3572
3579
  }
@@ -3581,7 +3588,7 @@ var Deparser = /*#__PURE__*/function () {
3581
3588
  var index = opts.indexOf('transaction_read_only');
3582
3589
  var obj = nodeOpts.options[index];
3583
3590
  var set = false;
3584
- var flag = Number(_this18.deparse(dotty.get(obj, 'DefElem.arg'), context));
3591
+ var flag = Number(_this19.deparse(dotty.get(obj, 'DefElem.arg'), context));
3585
3592
 
3586
3593
  if (flag > 0) {
3587
3594
  set = true;
@@ -3685,7 +3692,7 @@ var Deparser = /*#__PURE__*/function () {
3685
3692
  }, {
3686
3693
  key: 'ObjectWithArgs',
3687
3694
  value: function ObjectWithArgs(node) {
3688
- var _this19 = this;
3695
+ var _this20 = this;
3689
3696
 
3690
3697
  var context = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
3691
3698
  var output = [];
@@ -3703,7 +3710,7 @@ var Deparser = /*#__PURE__*/function () {
3703
3710
  return 'NONE';
3704
3711
  }
3705
3712
 
3706
- return _this19.deparse(arg, context);
3713
+ return _this20.deparse(arg, context);
3707
3714
  }).join(','));
3708
3715
  output.push(')');
3709
3716
  }
@@ -3780,7 +3787,7 @@ var Deparser = /*#__PURE__*/function () {
3780
3787
  }, {
3781
3788
  key: 'TypeName',
3782
3789
  value: function TypeName(node) {
3783
- var _this20 = this;
3790
+ var _this21 = this;
3784
3791
 
3785
3792
  var context = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
3786
3793
 
@@ -3798,7 +3805,7 @@ var Deparser = /*#__PURE__*/function () {
3798
3805
 
3799
3806
  if (node.typmods != null) {
3800
3807
  args = node.typmods.map(function (item) {
3801
- return _this20.deparse(item, context);
3808
+ return _this21.deparse(item, context);
3802
3809
  });
3803
3810
  }
3804
3811
 
@@ -3825,7 +3832,7 @@ var Deparser = /*#__PURE__*/function () {
3825
3832
  }, {
3826
3833
  key: 'WindowDef',
3827
3834
  value: function WindowDef(node) {
3828
- var _this21 = this;
3835
+ var _this22 = this;
3829
3836
 
3830
3837
  var context = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
3831
3838
  var output = [];
@@ -3849,7 +3856,7 @@ var Deparser = /*#__PURE__*/function () {
3849
3856
  if (node.partitionClause) {
3850
3857
  var partition = ['PARTITION BY'];
3851
3858
  var clause = node.partitionClause.map(function (item) {
3852
- return _this21.deparse(item, context);
3859
+ return _this22.deparse(item, context);
3853
3860
  });
3854
3861
  partition.push(clause.join(', '));
3855
3862
  windowParts.push(partition.join(' '));
@@ -3859,7 +3866,7 @@ var Deparser = /*#__PURE__*/function () {
3859
3866
  if (node.orderClause) {
3860
3867
  windowParts.push('ORDER BY');
3861
3868
  var orders = node.orderClause.map(function (item) {
3862
- return _this21.deparse(item);
3869
+ return _this22.deparse(item);
3863
3870
  });
3864
3871
  windowParts.push(orders.join(', '));
3865
3872
  useParens = true;
@@ -3907,6 +3914,23 @@ var Deparser = /*#__PURE__*/function () {
3907
3914
  return output.join(' ');
3908
3915
  }
3909
3916
  }, {
3917
+ key: 'CallStmt',
3918
+ value: function CallStmt(node) {
3919
+ var context = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
3920
+ var output = ['CALL'];
3921
+ output.push(this.deparse(node.funccall.funcname[0]));
3922
+
3923
+ if (node.funccall.args && node.funccall.args.length) {
3924
+ // we have arguments
3925
+ output.push('(' + this.list(node.funccall.args, ', ', '', context) + ')');
3926
+ } else {
3927
+ // just close parens
3928
+ output.push('()');
3929
+ }
3930
+
3931
+ return output.join(' ');
3932
+ }
3933
+ }, {
3910
3934
  key: "deparseFrameOptions",
3911
3935
  value: function deparseFrameOptions(options, refName, startOffset, endOffset) {
3912
3936
  // https://github.com/pganalyze/libpg_query/blob/442b1748d06364ecd3779bc558899176c02efaf0/src/postgres/include/nodes/parsenodes.h#L505-L522
@@ -4049,7 +4073,7 @@ var Deparser = /*#__PURE__*/function () {
4049
4073
  }, {
4050
4074
  key: "deparseInterval",
4051
4075
  value: function deparseInterval(node) {
4052
- var _this22 = this;
4076
+ var _this23 = this;
4053
4077
 
4054
4078
  var type = ['interval'];
4055
4079
 
@@ -4059,7 +4083,7 @@ var Deparser = /*#__PURE__*/function () {
4059
4083
 
4060
4084
  if (node.typmods) {
4061
4085
  var typmods = node.typmods.map(function (item) {
4062
- return _this22.deparse(item);
4086
+ return _this23.deparse(item);
4063
4087
  });
4064
4088
  var intervals = this.interval(typmods[0]); // SELECT interval(0) '1 day 01:23:45.6789'
4065
4089
 
@@ -2143,6 +2143,11 @@ export default class Deparser {
2143
2143
  if (opt.DefElem.defname === 'cascade' && opt.DefElem.arg.Integer.ival === 1) {
2144
2144
  output.push('CASCADE');
2145
2145
  }
2146
+
2147
+ if (opt.DefElem.defname === 'schema') {
2148
+ output.push('WITH SCHEMA');
2149
+ output.push(this.quote(this.deparse(opt.DefElem.arg)));
2150
+ }
2146
2151
  });
2147
2152
  }
2148
2153
 
@@ -3582,6 +3587,21 @@ export default class Deparser {
3582
3587
  return output.join(' ');
3583
3588
  }
3584
3589
 
3590
+ ['CallStmt'](node, context = {}) {
3591
+ const output = ['CALL'];
3592
+ output.push(this.deparse(node.funccall.funcname[0]));
3593
+
3594
+ if (node.funccall.args && node.funccall.args.length) {
3595
+ // we have arguments
3596
+ output.push('(' + this.list(node.funccall.args, ', ', '', context) + ')');
3597
+ } else {
3598
+ // just close parens
3599
+ output.push('()');
3600
+ }
3601
+
3602
+ return output.join(' ');
3603
+ }
3604
+
3585
3605
  deparseFrameOptions(options, refName, startOffset, endOffset) {
3586
3606
  // https://github.com/pganalyze/libpg_query/blob/442b1748d06364ecd3779bc558899176c02efaf0/src/postgres/include/nodes/parsenodes.h#L505-L522
3587
3607
  const FRAMEOPTION_NONDEFAULT = 0x00001;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pgsql-deparser",
3
- "version": "13.3.2",
3
+ "version": "13.3.5",
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.2",
68
+ "pgsql-parser": "^13.3.5",
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": "e5b21f3c4f969dc1426498100cabe1608165ed78"
78
+ "gitHead": "ed7ccd5b72727e35fb4d081203101a90b3ed6ddc"
79
79
  }