pgsql-parser 13.3.10 → 13.3.13
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 +24 -0
- package/README.md +1 -1
- package/main/index.js +59 -14
- package/module/index.js +22 -14
- package/package.json +4 -4
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.13](https://github.com/pyramation/pgsql-parser/compare/pgsql-parser@13.3.12...pgsql-parser@13.3.13) (2022-08-31)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package pgsql-parser
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## [13.3.12](https://github.com/pyramation/pgsql-parser/compare/pgsql-parser@13.3.11...pgsql-parser@13.3.12) (2022-07-29)
|
|
15
|
+
|
|
16
|
+
**Note:** Version bump only for package pgsql-parser
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
## [13.3.11](https://github.com/pyramation/pgsql-parser/compare/pgsql-parser@13.3.10...pgsql-parser@13.3.11) (2022-05-20)
|
|
23
|
+
|
|
24
|
+
**Note:** Version bump only for package pgsql-parser
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
6
30
|
## [13.3.10](https://github.com/pyramation/pgsql-parser/compare/pgsql-parser@13.3.9...pgsql-parser@13.3.10) (2022-05-19)
|
|
7
31
|
|
|
8
32
|
**Note:** Version bump only for package pgsql-parser
|
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# pgsql-parser [](https://github.com/pyramation/pgsql-parser/actions/workflows/run-tests.yaml)
|
|
2
2
|
|
|
3
3
|
The real PostgreSQL parser for nodejs. The primary objective of this module is to provide symmetric parsing and deparsing of SQL statements. With this module you can modify parts of a SQL query statement and serialize the query tree back into a formatted SQL statement. It uses the *real* [PostgreSQL parser](https://github.com/pganalyze/libpg_query).
|
|
4
4
|
|
package/main/index.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
3
5
|
Object.defineProperty(exports, "__esModule", {
|
|
4
6
|
value: true
|
|
5
7
|
});
|
|
@@ -27,7 +29,11 @@ Object.defineProperty(exports, "parseFunction", {
|
|
|
27
29
|
return _libpgQuery.parsePlPgSQLSync;
|
|
28
30
|
}
|
|
29
31
|
});
|
|
30
|
-
exports.parse = void 0;
|
|
32
|
+
exports.parseAsync = exports.parse = void 0;
|
|
33
|
+
|
|
34
|
+
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
35
|
+
|
|
36
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
31
37
|
|
|
32
38
|
var _pgsqlDeparser = require("pgsql-deparser");
|
|
33
39
|
|
|
@@ -35,21 +41,60 @@ var _pgsqlEnums = require("pgsql-enums");
|
|
|
35
41
|
|
|
36
42
|
var _libpgQuery = require("libpg-query");
|
|
37
43
|
|
|
44
|
+
function mapStmt(_ref) {
|
|
45
|
+
var stmt = _ref.stmt,
|
|
46
|
+
stmt_len = _ref.stmt_len,
|
|
47
|
+
stmt_location = _ref.stmt_location;
|
|
48
|
+
return {
|
|
49
|
+
RawStmt: {
|
|
50
|
+
stmt: stmt,
|
|
51
|
+
stmt_len: stmt_len,
|
|
52
|
+
stmt_location: stmt_location || 0
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
|
|
38
57
|
var parse = function parse(sql) {
|
|
39
58
|
if (!sql) throw new Error('no SQL provided to parser');
|
|
40
59
|
var result = (0, _libpgQuery.parseQuerySync)(sql);
|
|
41
|
-
return result.stmts.map(
|
|
42
|
-
var stmt = _ref.stmt,
|
|
43
|
-
stmt_len = _ref.stmt_len,
|
|
44
|
-
stmt_location = _ref.stmt_location;
|
|
45
|
-
return {
|
|
46
|
-
RawStmt: {
|
|
47
|
-
stmt: stmt,
|
|
48
|
-
stmt_len: stmt_len,
|
|
49
|
-
stmt_location: stmt_location || 0
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
});
|
|
60
|
+
return result.stmts.map(mapStmt);
|
|
53
61
|
};
|
|
54
62
|
|
|
55
|
-
exports.parse = parse;
|
|
63
|
+
exports.parse = parse;
|
|
64
|
+
|
|
65
|
+
var parseAsync = /*#__PURE__*/function () {
|
|
66
|
+
var _ref2 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(sql) {
|
|
67
|
+
var result;
|
|
68
|
+
return _regenerator["default"].wrap(function _callee$(_context) {
|
|
69
|
+
while (1) {
|
|
70
|
+
switch (_context.prev = _context.next) {
|
|
71
|
+
case 0:
|
|
72
|
+
if (sql) {
|
|
73
|
+
_context.next = 2;
|
|
74
|
+
break;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
throw new Error('no SQL provided to parser');
|
|
78
|
+
|
|
79
|
+
case 2:
|
|
80
|
+
_context.next = 4;
|
|
81
|
+
return (0, _libpgQuery.parseQuery)(sql);
|
|
82
|
+
|
|
83
|
+
case 4:
|
|
84
|
+
result = _context.sent;
|
|
85
|
+
return _context.abrupt("return", result.stmts.map(mapStmt));
|
|
86
|
+
|
|
87
|
+
case 6:
|
|
88
|
+
case "end":
|
|
89
|
+
return _context.stop();
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}, _callee);
|
|
93
|
+
}));
|
|
94
|
+
|
|
95
|
+
return function parseAsync(_x) {
|
|
96
|
+
return _ref2.apply(this, arguments);
|
|
97
|
+
};
|
|
98
|
+
}();
|
|
99
|
+
|
|
100
|
+
exports.parseAsync = parseAsync;
|
package/module/index.js
CHANGED
|
@@ -1,21 +1,29 @@
|
|
|
1
1
|
import { Deparser, deparse } from 'pgsql-deparser';
|
|
2
2
|
import { enums } from 'pgsql-enums';
|
|
3
|
-
import { parseQuerySync, parsePlPgSQLSync as parseFunction } from 'libpg-query';
|
|
3
|
+
import { parseQuery, parseQuerySync, parsePlPgSQLSync as parseFunction } from 'libpg-query';
|
|
4
|
+
|
|
5
|
+
function mapStmt({
|
|
6
|
+
stmt,
|
|
7
|
+
stmt_len,
|
|
8
|
+
stmt_location
|
|
9
|
+
}) {
|
|
10
|
+
return {
|
|
11
|
+
RawStmt: {
|
|
12
|
+
stmt,
|
|
13
|
+
stmt_len,
|
|
14
|
+
stmt_location: stmt_location || 0
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
|
|
4
19
|
export const parse = sql => {
|
|
5
20
|
if (!sql) throw new Error('no SQL provided to parser');
|
|
6
21
|
const result = parseQuerySync(sql);
|
|
7
|
-
return result.stmts.map(
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
RawStmt: {
|
|
14
|
-
stmt,
|
|
15
|
-
stmt_len,
|
|
16
|
-
stmt_location: stmt_location || 0
|
|
17
|
-
}
|
|
18
|
-
};
|
|
19
|
-
});
|
|
22
|
+
return result.stmts.map(mapStmt);
|
|
23
|
+
};
|
|
24
|
+
export const parseAsync = async sql => {
|
|
25
|
+
if (!sql) throw new Error('no SQL provided to parser');
|
|
26
|
+
const result = await parseQuery(sql);
|
|
27
|
+
return result.stmts.map(mapStmt);
|
|
20
28
|
};
|
|
21
29
|
export { deparse, Deparser, enums, parseFunction };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pgsql-parser",
|
|
3
|
-
"version": "13.3.
|
|
3
|
+
"version": "13.3.13",
|
|
4
4
|
"description": "The real PostgreSQL query parser",
|
|
5
5
|
"author": "Dan Lynch <pyramation@gmail.com>",
|
|
6
6
|
"homepage": "https://github.com/pyramation/pgsql-parser",
|
|
@@ -74,8 +74,8 @@
|
|
|
74
74
|
"@babel/runtime": "^7.11.2",
|
|
75
75
|
"libpg-query": "13.2.5",
|
|
76
76
|
"minimist": "^1.2.6",
|
|
77
|
-
"pgsql-deparser": "^13.3.
|
|
78
|
-
"pgsql-enums": "^13.1.
|
|
77
|
+
"pgsql-deparser": "^13.3.13",
|
|
78
|
+
"pgsql-enums": "^13.1.3"
|
|
79
79
|
},
|
|
80
|
-
"gitHead": "
|
|
80
|
+
"gitHead": "6161588d5b59842d0b5281e8819ddf363a3e3aea"
|
|
81
81
|
}
|