Skip to content

Commit 37b40ed

Browse files
authored
Merge pull request #91 from launchql/17-upgrade-from-15-latest
17 upgrade from 15 latest
2 parents c713c41 + 9cca25d commit 37b40ed

File tree

8 files changed

+59166
-47260
lines changed

8 files changed

+59166
-47260
lines changed

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ WASM_OUT_DIR := wasm
22
WASM_OUT_NAME := libpg-query
33
WASM_MODULE_NAME := PgQueryModule
44
LIBPG_QUERY_REPO := https://github.com/pganalyze/libpg_query.git
5-
LIBPG_QUERY_TAG := 15-4.2.4
5+
LIBPG_QUERY_TAG := 17-6.1.0
6+
67
CACHE_DIR := .cache
78

89
OS ?= $(shell uname -s)

docker/readme.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ docker run \
1919
# build inside the docker image
2020

2121
```sh
22-
branch=15-latest
22+
branch=17-6.1.0
2323
mkdir git_clone_dir && cd git_clone_dir
2424
git clone -b $branch --single-branch https://github.com/launchql/libpg-query-node
2525
cd libpg-query-node/
@@ -40,7 +40,7 @@ npm publish
4040
to build manually using `libpg_query`
4141

4242
```sh
43-
branch=15-latest
43+
branch=17-6.1.0
4444
mkdir git_clone_dir && cd git_clone_dir
4545
git clone -b $branch --single-branch https://github.com/pganalyze/libpg_query.git
4646
cd libpg_query/

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "libpg-query",
3-
"version": "15.2.0-rc.deparse.3",
3+
"version": "17.1.0",
44
"description": "The real PostgreSQL query parser",
55
"homepage": "https://github.com/launchql/libpg-query-node",
66
"main": "index.js",
@@ -31,7 +31,7 @@
3131
}
3232
},
3333
"scripts": {
34-
"protogen": "node ./script/protogen.js 15-4.2.4",
34+
"protogen": "node ./script/protogen.js 17-6.1.0",
3535
"clean": "rimraf build",
3636
"configure": "node-pre-gyp configure",
3737
"install": "node-pre-gyp install --fallback-to-build --loglevel verbose",
@@ -66,7 +66,7 @@
6666
"@emnapi/runtime": "^0.43.1",
6767
"@launchql/protobufjs": "7.2.6",
6868
"@mapbox/node-pre-gyp": "^1.0.8",
69-
"@pgsql/types": "^15.0.1",
69+
"@pgsql/types": "^17.0.0",
7070
"node-addon-api": "^7.0.0",
7171
"node-gyp": "^10.0.1"
7272
},

proto.js

Lines changed: 58785 additions & 47246 deletions
Large diffs are not rendered by default.

script/buildAddon.bat

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
@echo off
22

3-
set commit=db39825bc7c1ddd45962ec6a626d740b7f8f027a
4-
set branch=15-latest
3+
set commit=1c1a32ed2f4c7799830d50bf4cb159222aafec48
4+
set branch=17-6.1.0
55

66
setlocal enabledelayedexpansion
77

script/buildAddon.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#!/usr/bin/env bash
22

33
# Set the desired commit hash and branch
4-
commit=db39825bc7c1ddd45962ec6a626d740b7f8f027a
5-
branch=15-latest
4+
commit=1c1a32ed2f4c7799830d50bf4cb159222aafec48
5+
branch=17-6.1.0
66

77
# Remember current directory and create a new, unique, temporary directory
88
rDIR=$(pwd)

test/index.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,41 @@ describe("Queries", () => {
9595
expect(deparsed).to.eq(`INSERT INTO people (name, age) VALUES ('John', 28), ('Jane', 22)`)
9696
});
9797

98+
it("sync function should return a same SQL (update)", async () => {
99+
const testQuery = "UPDATE people SET age = age + 1 WHERE name = 'John';";
100+
const parsed = query.parseQuerySync(testQuery);
101+
const deparsed = query.deparseSync(parsed);
102+
expect(deparsed).to.eq("UPDATE people SET age = age + 1 WHERE name = 'John'");
103+
});
104+
105+
it("sync function should return a same SQL (join and where)", async () => {
106+
const testQuery = "select a.id, b.name from table_a a join table_b b on a.id = b.a_id where b.status = 'active';";
107+
const parsed = query.parseQuerySync(testQuery);
108+
const deparsed = query.deparseSync(parsed);
109+
expect(deparsed).to.eq("SELECT a.id, b.name FROM table_a a JOIN table_b b ON a.id = b.a_id WHERE b.status = 'active'");
110+
});
111+
112+
it("sync function should return a same SQL (CTE)", async () => {
113+
const testQuery = "with recent as (select * from people where age > 30) select name from recent;";
114+
const parsed = query.parseQuerySync(testQuery);
115+
const deparsed = query.deparseSync(parsed);
116+
expect(deparsed).to.eq("WITH recent AS (SELECT * FROM people WHERE age > 30) SELECT name FROM recent");
117+
});
118+
119+
it("sync function should return a same SQL (create table)", async () => {
120+
const testQuery = `CREATE TABLE orders (
121+
id serial PRIMARY KEY,
122+
user_id integer NOT NULL,
123+
total numeric(10,2) DEFAULT 0.00,
124+
ordered_at timestamp with time zone DEFAULT now(),
125+
description text,
126+
CONSTRAINT fk_user FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE
127+
);`;
128+
const parsed = query.parseQuerySync(testQuery);
129+
const deparsed = query.deparseSync(parsed);
130+
expect(deparsed).to.eq(`CREATE TABLE orders (id serial PRIMARY KEY, user_id int NOT NULL, total numeric(10, 2) DEFAULT 0.00, ordered_at timestamp with time zone DEFAULT now(), description text, CONSTRAINT fk_user FOREIGN KEY (user_id) REFERENCES users (id) ON DELETE CASCADE)`);
131+
});
132+
98133
it("should reject on bogus input", async () => {
99134
return query.deparse({stmts: [{}]}).then(
100135
() => {

0 commit comments

Comments
 (0)