Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
strategy:
matrix:
package:
- { name: 'full', path: 'full', version: '17' }
- { name: 'full', path: 'full', version: '18' }
- { name: 'v13', path: 'versions/13', version: '13' }
- { name: 'v14', path: 'versions/14', version: '14' }
- { name: 'v15', path: 'versions/15', version: '15' }
Expand Down Expand Up @@ -78,7 +78,7 @@ jobs:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
package:
- { name: 'full', path: 'full', version: '17' }
- { name: 'full', path: 'full', version: '18' }
- { name: 'v13', path: 'versions/13', version: '13' }
- { name: 'v14', path: 'versions/14', version: '14' }
- { name: 'v15', path: 'versions/15', version: '15' }
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ npm install @pgsql/enums
- **Just need to parse SQL?** → Use `libpg-query` (lightweight, all PG versions)
- **Need multiple versions at runtime?** → Use `@pgsql/parser` (dynamic version selection)
- **Need TypeScript types?** → Add `@pgsql/types` and/or `@pgsql/enums`
- **Need fingerprint, normalize, or deparse?** → Use `@libpg-query/parser` (PG 17 only)
- **Need fingerprint, normalize, scan, or PL/pgSQL parsing?** → Use `@libpg-query/parser` (PG 18)


## API Documentation
Expand Down
4 changes: 2 additions & 2 deletions full/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ WASM_OUT_DIR := wasm
WASM_OUT_NAME := libpg-query
WASM_MODULE_NAME := PgQueryModule
LIBPG_QUERY_REPO := https://github.com/pganalyze/libpg_query.git
LIBPG_QUERY_TAG := 17-6.1.0
LIBPG_QUERY_TAG := 18.0.0

CACHE_DIR := .cache

Expand Down Expand Up @@ -57,7 +57,7 @@ ifdef EMSCRIPTEN
-I$(LIBPG_QUERY_DIR) \
-I$(LIBPG_QUERY_DIR)/vendor \
-L$(LIBPG_QUERY_DIR) \
-sEXPORTED_FUNCTIONS="['_malloc','_free','_wasm_parse_query','_wasm_parse_query_protobuf','_wasm_get_protobuf_len','_wasm_deparse_protobuf','_wasm_parse_plpgsql','_wasm_fingerprint','_wasm_normalize_query','_wasm_scan','_wasm_parse_query_detailed','_wasm_free_detailed_result','_wasm_free_string','_wasm_parse_query_raw','_wasm_free_parse_result']" \
-sEXPORTED_FUNCTIONS="['_malloc','_free','_wasm_parse_query','_wasm_parse_plpgsql','_wasm_fingerprint','_wasm_normalize_query','_wasm_scan','_wasm_parse_query_detailed','_wasm_free_detailed_result','_wasm_free_string','_wasm_parse_query_raw','_wasm_free_parse_result']" \
-sEXPORTED_RUNTIME_METHODS="['lengthBytesUTF8','stringToUTF8','UTF8ToString','getValue','HEAPU8','HEAPU32']" \
-sEXPORT_NAME="$(WASM_MODULE_NAME)" \
-sENVIRONMENT="web,node,worker" \
Expand Down
41 changes: 2 additions & 39 deletions full/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,30 +95,6 @@ import { parsePlPgSQLSync } from '@libpg-query/parser';
const result = parsePlPgSQLSync(functionSql);
```

### `deparse(parseTree: ParseResult): Promise<string>`

Converts a parse tree back to SQL string. Returns a Promise for the SQL string.

```typescript
import { parse, deparse } from '@libpg-query/parser';

const parseTree = await parse('SELECT * FROM users WHERE active = true');
const sql = await deparse(parseTree);
// Returns: string - reconstructed SQL query
```

### `deparseSync(parseTree: ParseResult): string`

Synchronous version that converts a parse tree back to SQL string directly.

```typescript
import { parseSync, deparseSync } from '@libpg-query/parser';

const parseTree = parseSync('SELECT * FROM users WHERE active = true');
const sql = deparseSync(parseTree);
// Returns: string - reconstructed SQL query
```

### `fingerprint(sql: string): Promise<string>`

Generates a unique fingerprint for a SQL query that can be used for query identification and caching. Returns a Promise for a 16-character fingerprint string.
Expand Down Expand Up @@ -195,11 +171,10 @@ The library provides both async and sync methods. Async methods handle initializ
Async methods handle initialization automatically and are always safe to use:

```typescript
import { parse, deparse, scan } from '@libpg-query/parser';
import { parse, scan } from '@libpg-query/parser';

// These handle initialization automatically
const result = await parse('SELECT * FROM users');
const sql = await deparse(result);
const tokens = await scan('SELECT * FROM users');
```

Expand Down Expand Up @@ -325,19 +300,7 @@ pnpm run test

## Versions

Our latest is built with `17-latest` branch from libpg_query


| PG Major Version | libpg_query | Branch | npm
|--------------------------|-------------|------------------------------------------------------------------------------------------------|---------|
| 17 | 17-latest | [`17-latest`](https://github.com/constructive-io/libpg-query-node/tree/17-latest) | [`libpg-query@17.2.0`](https://www.npmjs.com/package/libpg-query/v/latest)
| 16 | 16-latest | [`16-latest`](https://github.com/constructive-io/libpg-query-node/tree/16-latest) | [`libpg-query@16.2.0`](https://www.npmjs.com/package/libpg-query/v/16.2.0)
| 15 | 15-latest | [`15-latest`](https://github.com/constructive-io/libpg-query-node/tree/15-latest) | [`libpg-query@15.1.0`](https://www.npmjs.com/package/libpg-query/v/15.1.0)
| 14 | 14-latest | [`14-latest`](https://github.com/constructive-io/libpg-query-node/tree/14-latest) | [`libpg-query@14.0.0`](https://www.npmjs.com/package/libpg-query/v/14.0.0)
| 13 | 13-latest | [`13-latest`](https://github.com/constructive-io/libpg-query-node/tree/13-latest) | [`libpg-query@13.3.1`](https://www.npmjs.com/package/libpg-query/v/13.3.1)
| 12 | (n/a) | |
| 11 | (n/a) | |
| 10 | 10-latest | | `@1.3.1` ([tree](https://github.com/constructive-io/pgsql-parser/tree/39b7b1adc8914253226e286a48105785219a81ca)) |
Built with the `18-latest` branch from libpg_query (tag `18.0.0`), based on PostgreSQL 18.


## Troubleshooting
Expand Down
12 changes: 4 additions & 8 deletions full/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@
"access": "public"
},
"files": [
"wasm/*",
"proto.js"
"wasm/*"
],
"scripts": {
"clean": "pnpm wasm:clean && rimraf cjs esm",
Expand All @@ -22,9 +21,8 @@
"wasm:rebuild": "pnpm wasm:make rebuild",
"wasm:clean": "pnpm wasm:make clean",
"wasm:clean-cache": "pnpm wasm:make clean-cache",
"test": "node --test test/parsing.test.js test/deparsing.test.js test/fingerprint.test.js test/normalize.test.js test/plpgsql.test.js test/scan.test.js test/errors.test.js",
"yamlize": "node ./scripts/yamlize.js",
"protogen": "node ./scripts/protogen.js"
"test": "node --test test/parsing.test.js test/fingerprint.test.js test/normalize.test.js test/plpgsql.test.js test/scan.test.js test/errors.test.js",
"yamlize": "node ./scripts/yamlize.js"
},
"author": "Constructive <developers@constructive.io>",
"license": "MIT",
Expand All @@ -33,12 +31,10 @@
"url": "git://github.com/constructive-io/libpg-query-node.git"
},
"devDependencies": {
"@launchql/proto-cli": "1.25.0",
"@yamlize/cli": "^0.8.0"
},
"dependencies": {
"@pgsql/types": "^17.6.0",
"@launchql/protobufjs": "7.2.6"
"@pgsql/types": "^18.0.0"
},
"keywords": [
"sql",
Expand Down
Loading
Loading