Skip to content

Commit 5ea5ded

Browse files
committed
Merge branch 'tom/deparse-pr' into 15-deparse
# By Dan Lynch (33) and others # Via GitHub (12) and Dan Lynch (1) * tom/deparse-pr: (41 commits) package up protogen lock and proto use protobufjs with modifications for [json_name] pkg scripts workflow pkg workflow yarn workflow workflow workflow workflow workflow build wasm update wasm to use latest 16 libpg_query workflows remove build step from workflow update locks, workflows update gitignore and readme ... # Conflicts: # .github/workflows/build-dry-run.yml # .github/workflows/run-tests-linux.yml # .github/workflows/run-tests-mac.yml # .github/workflows/run-tests-win.yml # README.md # docker/readme.md # index.d.ts # package.json # script/buildAddon.bat # script/buildAddon.sh # yarn.lock
2 parents 1f95e07 + fa16a64 commit 5ea5ded

File tree

19 files changed

+107450
-244
lines changed

19 files changed

+107450
-244
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ libs/
44
npm-debug.log
55
libpg_query/**/*.a
66
libpg_query/**/*.h
7+
libpg_query/**/*.proto
78
wasm/libpg-query.js
89
*.wasm
910
.cache

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
<a href="https://github.com/launchql/libpg-query-node/actions/workflows/run-tests-win.yml">
1919
<img height="20" src="https://github.com/launchql/libpg-query-node/actions/workflows/run-tests-win.yml/badge.svg" />
2020
</a>
21-
2221
</p>
2322

2423
The real PostgreSQL parser, exposed for nodejs.

index.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ export function parseQuery(sql: string): Promise<ParseResult>;
33
export function parsePlPgSQL(funcsSql: string): Promise<any>;
44
export function parseQuerySync(sql: string): ParseResult;
55
export function parsePlPgSQLSync(funcsSql: string): any;
6+
export function deparse(parseTree: any): Promise<string>;
7+
export function deparseSync(parseTree: any): any;
68
export function fingerprint(sql: string): Promise<string>;
79
export function fingerprintSync(sql: string): string;
810
export * from '@pgsql/types';

index.js

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
const PgQuery = require('./build/Release/queryparser.node');
1+
const PgQuery = require('./build/Release/queryparser');
2+
const { pg_query } = require('./proto');
3+
24

35
module.exports = {
46
parseQuery(query) {
@@ -9,6 +11,16 @@ module.exports = {
911
});
1012
},
1113

14+
deparse(parseTree) {
15+
const msg = pg_query.ParseResult.fromObject(parseTree);
16+
const data = pg_query.ParseResult.encode(msg).finish();
17+
return new Promise((resolve, reject) => {
18+
PgQuery.deparseAsync(data, (err, result) => {
19+
err ? reject(err) : resolve(result);
20+
});
21+
});
22+
},
23+
1224
parsePlPgSQL(query) {
1325
return new Promise((resolve, reject) => {
1426
PgQuery.parsePlPgSQLAsync(query, (err, result) => {
@@ -21,6 +33,12 @@ module.exports = {
2133
return JSON.parse(PgQuery.parseQuerySync(query));
2234
},
2335

36+
deparseSync(parseTree) {
37+
const msg = pg_query.ParseResult.fromObject(parseTree);
38+
const data = pg_query.ParseResult.encode(msg).finish();
39+
return PgQuery.deparseSync(data);
40+
},
41+
2442
parsePlPgSQLSync(query) {
2543
return JSON.parse(PgQuery.parsePlPgSQLSync(query));
2644
},

libpg_query/protobuf/.gitkeep

Whitespace-only changes.

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
}
3131
},
3232
"scripts": {
33+
"protogen": "node ./script/protogen.js 16-latest",
3334
"clean": "rimraf build",
3435
"configure": "node-pre-gyp configure",
3536
"install": "node-pre-gyp install --fallback-to-build --loglevel verbose",
@@ -43,14 +44,15 @@
4344
"test": "mocha --timeout 5000",
4445
"binary:build": "node-pre-gyp rebuild package",
4546
"binary:publish": "AWS_PROFILE=supabase-dev node-pre-gyp publish"
46-
},
47+
},
4748
"author": "Dan Lynch <[email protected]> (http://github.com/pyramation)",
4849
"license": "LICENSE IN LICENSE",
4950
"repository": {
5051
"type": "git",
5152
"url": "git://github.com/launchql/libpg-query-node.git"
5253
},
5354
"devDependencies": {
55+
"@launchql/proto-cli": "1.25.0",
5456
"@yamlize/cli": "^0.8.0",
5557
"chai": "^3.5.0",
5658
"emnapi": "^0.43.1",
@@ -60,6 +62,7 @@
6062
},
6163
"dependencies": {
6264
"@emnapi/runtime": "^0.43.1",
65+
"@launchql/protobufjs": "7.2.6",
6366
"@mapbox/node-pre-gyp": "^1.0.8",
6467
"@pgsql/types": "^15.0.1",
6568
"node-addon-api": "^7.0.0",

0 commit comments

Comments
 (0)