pgsql-deparser 13.3.1 → 13.3.4

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.4](https://github.com/pyramation/pgsql-parser/compare/pgsql-deparser@13.3.3...pgsql-deparser@13.3.4) (2022-04-19)
7
+
8
+ **Note:** Version bump only for package pgsql-deparser
9
+
10
+
11
+
12
+
13
+
14
+ ## [13.3.3](https://github.com/pyramation/pgsql-parser/compare/pgsql-deparser@13.3.2...pgsql-deparser@13.3.3) (2022-04-19)
15
+
16
+ **Note:** Version bump only for package pgsql-deparser
17
+
18
+
19
+
20
+
21
+
22
+ ## [13.3.2](https://github.com/pyramation/pgsql-parser/compare/pgsql-deparser@13.3.1...pgsql-deparser@13.3.2) (2022-04-19)
23
+
24
+ **Note:** Version bump only for package pgsql-deparser
25
+
26
+
27
+
28
+
29
+
6
30
  ## [13.3.1](https://github.com/pyramation/pgsql-parser/compare/pgsql-deparser@13.3.0...pgsql-deparser@13.3.1) (2022-04-13)
7
31
 
8
32
  **Note:** Version bump only for package pgsql-deparser
package/main/deparser.js CHANGED
@@ -2561,7 +2561,9 @@ var Deparser = /*#__PURE__*/function () {
2561
2561
  value: function ViewStmt(node) {
2562
2562
  var context = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2563
2563
  var output = [];
2564
- output.push('CREATE VIEW');
2564
+ output.push('CREATE');
2565
+ if (node.replace) output.push('OR REPLACE');
2566
+ output.push('VIEW');
2565
2567
  output.push(this.RangeVar(node.view, context));
2566
2568
  output.push('AS');
2567
2569
  output.push(this.deparse(node.query, context));
@@ -3888,6 +3890,40 @@ var Deparser = /*#__PURE__*/function () {
3888
3890
  return output.join(' ');
3889
3891
  }
3890
3892
  }, {
3893
+ key: 'CopyStmt',
3894
+ value: function CopyStmt(node) {
3895
+ var _node$options;
3896
+
3897
+ var context = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
3898
+ var output = ['COPY'];
3899
+ output.push('(' + this.deparse(node.query, context) + ')');
3900
+ output.push('TO');
3901
+ output.push("'".concat(node.filename, "'"));
3902
+
3903
+ if (((_node$options = node.options) === null || _node$options === void 0 ? void 0 : _node$options.length) > 0 && node.options[0].DefElem.defname === 'format') {
3904
+ output.push("(FORMAT '".concat(this.deparse(node.options[0].DefElem.arg), "')"));
3905
+ }
3906
+
3907
+ return output.join(' ');
3908
+ }
3909
+ }, {
3910
+ key: 'CallStmt',
3911
+ value: function CallStmt(node) {
3912
+ var context = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
3913
+ var output = ['CALL'];
3914
+ output.push(this.deparse(node.funccall.funcname[0]));
3915
+
3916
+ if (node.funccall.args && node.funccall.args.length) {
3917
+ // we have arguments
3918
+ output.push('(' + this.list(node.funccall.args, ', ', '', context) + ')');
3919
+ } else {
3920
+ // just close parens
3921
+ output.push('()');
3922
+ }
3923
+
3924
+ return output.join(' ');
3925
+ }
3926
+ }, {
3891
3927
  key: "deparseFrameOptions",
3892
3928
  value: function deparseFrameOptions(options, refName, startOffset, endOffset) {
3893
3929
  // https://github.com/pganalyze/libpg_query/blob/442b1748d06364ecd3779bc558899176c02efaf0/src/postgres/include/nodes/parsenodes.h#L505-L522
@@ -2331,7 +2331,9 @@ export default class Deparser {
2331
2331
 
2332
2332
  ['ViewStmt'](node, context = {}) {
2333
2333
  const output = [];
2334
- output.push('CREATE VIEW');
2334
+ output.push('CREATE');
2335
+ if (node.replace) output.push('OR REPLACE');
2336
+ output.push('VIEW');
2335
2337
  output.push(this.RangeVar(node.view, context));
2336
2338
  output.push('AS');
2337
2339
  output.push(this.deparse(node.query, context));
@@ -3567,6 +3569,34 @@ export default class Deparser {
3567
3569
  return output.join(' ');
3568
3570
  }
3569
3571
 
3572
+ ['CopyStmt'](node, context = {}) {
3573
+ const output = ['COPY'];
3574
+ output.push('(' + this.deparse(node.query, context) + ')');
3575
+ output.push('TO');
3576
+ output.push(`'${node.filename}'`);
3577
+
3578
+ if (node.options?.length > 0 && node.options[0].DefElem.defname === 'format') {
3579
+ output.push(`(FORMAT '${this.deparse(node.options[0].DefElem.arg)}')`);
3580
+ }
3581
+
3582
+ return output.join(' ');
3583
+ }
3584
+
3585
+ ['CallStmt'](node, context = {}) {
3586
+ const output = ['CALL'];
3587
+ output.push(this.deparse(node.funccall.funcname[0]));
3588
+
3589
+ if (node.funccall.args && node.funccall.args.length) {
3590
+ // we have arguments
3591
+ output.push('(' + this.list(node.funccall.args, ', ', '', context) + ')');
3592
+ } else {
3593
+ // just close parens
3594
+ output.push('()');
3595
+ }
3596
+
3597
+ return output.join(' ');
3598
+ }
3599
+
3570
3600
  deparseFrameOptions(options, refName, startOffset, endOffset) {
3571
3601
  // https://github.com/pganalyze/libpg_query/blob/442b1748d06364ecd3779bc558899176c02efaf0/src/postgres/include/nodes/parsenodes.h#L505-L522
3572
3602
  const FRAMEOPTION_NONDEFAULT = 0x00001;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pgsql-deparser",
3
- "version": "13.3.1",
3
+ "version": "13.3.4",
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.1",
68
+ "pgsql-parser": "^13.3.4",
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": "f829716e347d70bb9840cf40c1e85b790b45424f"
78
+ "gitHead": "39108ed988f69a32d7465d8471d3ce9fd2a3b521"
79
79
  }