Skip to content

Commit cf90dda

Browse files
committed
skip lines separation for future tasks
1 parent 287283b commit cf90dda

File tree

4 files changed

+183
-133
lines changed

4 files changed

+183
-133
lines changed

README.md

Lines changed: 43 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,6 @@
1818

1919
A comprehensive monorepo for PostgreSQL Abstract Syntax Tree (AST) parsing, manipulation, and code generation. This collection of packages provides everything you need to work with PostgreSQL at the AST level, from parsing SQL queries to generating type-safe TypeScript definitions.
2020

21-
## 📦 Packages
22-
23-
| Package | Description | Key Features |
24-
|---------|-------------|--------------|
25-
| [**pgsql-parser**](./packages/parser) | The real PostgreSQL parser for Node.js | • Uses actual PostgreSQL C parser via WebAssembly<br>• Symmetric parsing and deparsing<br>• Battle-tested with 23,000+ SQL statements |
26-
| [**pgsql-deparser**](./packages/deparser) | Lightning-fast SQL generation from AST | • Pure TypeScript, zero runtime dependencies<br>• No WebAssembly overhead<br>• Perfect for AST-to-SQL conversion only |
27-
| [**@pgsql/cli**](./packages/pgsql-cli) | Unified CLI for all PostgreSQL AST operations | • Parse SQL to AST<br>• Deparse AST to SQL<br>• Generate TypeScript from protobuf<br>• Single tool for all operations |
28-
| [**@pgsql/utils**](./packages/utils) | Type-safe AST node creation utilities | • Programmatic AST construction<br>• Runtime Schema<br>• Seamless integration with types |
29-
| [**pg-proto-parser**](./packages/proto-parser) | PostgreSQL protobuf parser and code generator | • Generate TypeScript interfaces from protobuf<br>• Create enum mappings and utilities<br>• AST helper generation |
30-
3121
## 🚀 Quick Start
3222

3323
### Installation
@@ -70,6 +60,41 @@ const sql = await deparse(ast);
7060
console.log(sql); // SELECT * FROM users WHERE id = 1
7161
```
7262

63+
#### Build AST with Types
64+
```typescript
65+
import { deparse } from 'pgsql-deparser';
66+
import { SelectStmt } from '@pgsql/types';
67+
68+
const stmt: { SelectStmt: SelectStmt } = {
69+
SelectStmt: {
70+
targetList: [
71+
{
72+
ResTarget: {
73+
val: {
74+
ColumnRef: {
75+
fields: [{ A_Star: {} }]
76+
}
77+
}
78+
}
79+
}
80+
],
81+
fromClause: [
82+
{
83+
RangeVar: {
84+
relname: 'some_table',
85+
inh: true,
86+
relpersistence: 'p'
87+
}
88+
}
89+
],
90+
limitOption: 'LIMIT_OPTION_DEFAULT',
91+
op: 'SETOP_NONE'
92+
}
93+
};
94+
95+
await deparse(stmt);
96+
```
97+
7398
#### Build AST Programmatically
7499
```typescript
75100
import * as t from '@pgsql/utils';
@@ -98,19 +123,16 @@ const stmt: { SelectStmt: SelectStmt } = t.nodes.selectStmt({
98123
await deparse(stmt);
99124
```
100125

101-
#### Use the CLI
102-
```bash
103-
npm install -g @pgsql/cli
104-
105-
# Parse SQL file
106-
pgsql parse query.sql
126+
## 📦 Packages
107127

108-
# Convert AST to SQL
109-
pgsql deparse ast.json
128+
| Package | Description | Key Features |
129+
|---------|-------------|--------------|
130+
| [**pgsql-parser**](./packages/parser) | The real PostgreSQL parser for Node.js | • Uses actual PostgreSQL C parser via WebAssembly<br>• Symmetric parsing and deparsing<br>• Battle-tested with 23,000+ SQL statements |
131+
| [**pgsql-deparser**](./packages/deparser) | Lightning-fast SQL generation from AST | • Pure TypeScript, zero runtime dependencies<br>• No WebAssembly overhead<br>• Perfect for AST-to-SQL conversion only |
132+
| [**@pgsql/cli**](./packages/pgsql-cli) | Unified CLI for all PostgreSQL AST operations | • Parse SQL to AST<br>• Deparse AST to SQL<br>• Generate TypeScript from protobuf<br>• Single tool for all operations |
133+
| [**@pgsql/utils**](./packages/utils) | Type-safe AST node creation utilities | • Programmatic AST construction<br>• Runtime Schema<br>• Seamless integration with types |
134+
| [**pg-proto-parser**](./packages/proto-parser) | PostgreSQL protobuf parser and code generator | • Generate TypeScript interfaces from protobuf<br>• Create enum mappings and utilities<br>• AST helper generation |
110135

111-
# Generate TypeScript from protobuf
112-
pgsql proto-gen --inFile pg_query.proto --outDir out --types --enums
113-
```
114136

115137
## 🛠️ Development
116138

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
export type SkipTest = [
2+
versionPrevious: number,
3+
versionNext: number,
4+
test: string,
5+
reason: string
6+
];
7+
8+
export { parserErrors } from './parser-errors';
9+
export { transformerErrors } from './transformer-errors';
10+
11+
import { parserErrors } from './parser-errors';
12+
import { transformerErrors } from './transformer-errors';
13+
14+
// Combined export for backward compatibility
15+
export const skipTests: SkipTest[] = [
16+
...parserErrors,
17+
...transformerErrors
18+
];
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
export type SkipTest = [
2+
versionPrevious: number,
3+
versionNext: number,
4+
test: string,
5+
reason: string
6+
];
7+
8+
export const parserErrors: SkipTest[] = [
9+
[16, 17, "latest/postgres/create_am-62.sql", "16-17 parser fails with 'syntax error at or near 'DEFAULT'"],
10+
11+
[15, 16, "latest/postgres/create_role-83.sql", "PG15 parser fails with \"syntax error at or near 'INHERIT'\""],
12+
[15, 16, "latest/postgres/create_role-80.sql", "PG15 parser fails with \"syntax error at or near 'OPTION'\""],
13+
[15, 16, "latest/postgres/create_am-96.sql", "PG15 parser fails with 'syntax error at or near 'DEFAULT'"],
14+
[15, 16, "latest/postgres/create_am-74.sql", "PG15 parser fails with 'syntax error at or near 'DEFAULT'"],
15+
[15, 16, "latest/postgres/create_am-65.sql", "PG15 parser fails with 'syntax error at or near 'DEFAULT'"],
16+
[15, 16, "latest/postgres/create_am-62.sql", "PG15 parser fails with 'syntax error at or near 'DEFAULT'"],
17+
[15, 16, "latest/postgres/create_am-109.sql", "PG15 parser fails with 'syntax error at or near 'DEFAULT'"],
18+
[15, 16, "latest/postgres/create_am-106.sql", "PG15 parser fails with 'syntax error at or near 'DEFAULT'"],
19+
20+
[14, 15, "misc/issues-5.sql", "PG14 parser fails with \"syntax error at or near 'NULLS'\""],
21+
[14, 15, "misc/issues-3.sql", "PG14 parser fails with \"syntax error at or near 'NULLS'\""],
22+
[14, 15, "latest/postgres/create_role-83.sql", "PG14 parser fails with \"syntax error at or near 'INHERIT'\""],
23+
[14, 15, "latest/postgres/create_role-80.sql", "PG14 parser fails with \"syntax error at or near 'OPTION'\""],
24+
[14, 15, "latest/postgres/create_index-85.sql", "PG14 parser fails with \"syntax error at or near 'NULLS'\""],
25+
[14, 15, "latest/postgres/create_index-83.sql", "PG14 parser fails with \"syntax error at or near 'NULLS'\""],
26+
[14, 15, "latest/postgres/create_index-82.sql", "PG14 parser fails with \"syntax error at or near 'NULLS'\""],
27+
[14, 15, "latest/postgres/create_index-72.sql", "PG14 parser fails with \"syntax error at or near 'NULLS'\""],
28+
[14, 15, "latest/postgres/create_index-71.sql", "PG14 parser fails with \"syntax error at or near 'NULLS'\""],
29+
[14, 15, "latest/postgres/create_index-326.sql", "PG14 parser fails with \"syntax error at end of input\""],
30+
[14, 15, "latest/postgres/create_index-184.sql", "PG14 parser fails with \"syntax error at or near 'NULLS'\""],
31+
[14, 15, "latest/postgres/create_am-96.sql", "PG14 parser fails with \"syntax error at or near 'ACCESS'\""],
32+
[14, 15, "latest/postgres/create_am-94.sql", "PG14 parser fails with \"syntax error at or near 'ACCESS'\""],
33+
[14, 15, "latest/postgres/create_am-90.sql", "PG14 parser fails with \"syntax error at or near 'ACCESS'\""],
34+
[14, 15, "latest/postgres/create_am-86.sql", "PG14 parser fails with \"syntax error at or near 'ACCESS'\""],
35+
[14, 15, "latest/postgres/create_am-75.sql", "PG14 parser fails with \"syntax error at or near 'ACCESS'\""],
36+
[14, 15, "latest/postgres/create_am-74.sql", "PG14 parser fails with \"syntax error at or near 'ACCESS'\""],
37+
[14, 15, "latest/postgres/create_am-73.sql", "PG14 parser fails with \"syntax error at or near 'ACCESS'\""],
38+
[14, 15, "latest/postgres/create_am-70.sql", "PG14 parser fails with \"syntax error at or near 'ACCESS'\""],
39+
[14, 15, "latest/postgres/create_am-65.sql", "PG14 parser fails with \"syntax error at or near 'ACCESS'\""],
40+
[14, 15, "latest/postgres/create_am-62.sql", "PG14 parser fails with \"syntax error at or near 'ACCESS'\""],
41+
[14, 15, "latest/postgres/create_am-57.sql", "PG14 parser fails with \"syntax error at or near 'ACCESS'\""],
42+
[14, 15, "latest/postgres/create_am-55.sql", "PG14 parser fails with \"syntax error at or near 'ACCESS'\""],
43+
[14, 15, "latest/postgres/create_am-53.sql", "PG14 parser fails with \"syntax error at or near 'ACCESS'\""],
44+
[14, 15, "latest/postgres/create_am-112.sql", "PG14 parser fails with \"syntax error at or near 'ACCESS'\""],
45+
[14, 15, "latest/postgres/create_am-109.sql", "PG14 parser fails with \"syntax error at or near 'ACCESS'\""],
46+
[14, 15, "latest/postgres/create_am-106.sql", "PG14 parser fails with \"syntax error at or near 'ACCESS'\""],
47+
[14, 15, "latest/postgres/create_am-104.sql", "PG14 parser fails with \"syntax error at or near 'ACCESS'\""],
48+
49+
[13, 14, "misc/issues-5.sql", "PG13 parser fails with \"syntax error at or near 'NULLS'\""],
50+
[13, 14, "misc/issues-3.sql", "PG13 parser fails with \"syntax error at or near 'NULLS'\""],
51+
[13, 14, "latest/postgres/create_view-281.sql", "PG13 parser fails with \"syntax error at or near 'f'\""],
52+
[13, 14, "latest/postgres/create_view-132.sql", "PG13 parser fails with \"syntax error at or near 'as'\""],
53+
[13, 14, "latest/postgres/create_view-130.sql", "PG13 parser fails with \"syntax error at or near 'as'\""],
54+
[13, 14, "latest/postgres/create_schema-9.sql", "PG13 parser fails with \"syntax error at or near 'CURRENT_ROLE'\""],
55+
[13, 14, "latest/postgres/create_schema-8.sql", "PG13 parser fails with \"syntax error at or near 'CURRENT_ROLE'\""],
56+
[13, 14, "latest/postgres/create_schema-27.sql", "PG13 parser fails with \"syntax error at or near 'CURRENT_ROLE'\""],
57+
[13, 14, "latest/postgres/create_schema-26.sql", "PG13 parser fails with \"syntax error at or near 'CURRENT_ROLE'\""],
58+
[13, 14, "latest/postgres/create_schema-25.sql", "PG13 parser fails with \"syntax error at or near 'CURRENT_ROLE'\""],
59+
[13, 14, "latest/postgres/create_schema-24.sql", "PG13 parser fails with \"syntax error at or near 'CURRENT_ROLE'\""],
60+
[13, 14, "latest/postgres/create_schema-23.sql", "PG13 parser fails with \"syntax error at or near 'CURRENT_ROLE'\""],
61+
[13, 14, "latest/postgres/create_schema-22.sql", "PG13 parser fails with \"syntax error at or near 'CURRENT_ROLE'\""],
62+
[13, 14, "latest/postgres/create_schema-21.sql", "PG13 parser fails with \"syntax error at or near 'CURRENT_ROLE'\""],
63+
[13, 14, "latest/postgres/create_schema-20.sql", "PG13 parser fails with \"syntax error at or near 'CURRENT_ROLE'\""],
64+
[13, 14, "latest/postgres/create_schema-19.sql", "PG13 parser fails with \"syntax error at or near 'CURRENT_ROLE'\""],
65+
[13, 14, "latest/postgres/create_schema-18.sql", "PG13 parser fails with \"syntax error at or near 'CURRENT_ROLE'\""],
66+
[13, 14, "latest/postgres/create_schema-17.sql", "PG13 parser fails with \"syntax error at or near 'CURRENT_ROLE'\""],
67+
[13, 14, "latest/postgres/create_schema-16.sql", "PG13 parser fails with \"syntax error at or near 'CURRENT_ROLE'\""],
68+
[13, 14, "latest/postgres/create_schema-15.sql", "PG13 parser fails with \"syntax error at or near 'CURRENT_ROLE'\""],
69+
[13, 14, "latest/postgres/create_schema-14.sql", "PG13 parser fails with \"syntax error at or near 'CURRENT_ROLE'\""],
70+
[13, 14, "latest/postgres/create_schema-13.sql", "PG13 parser fails with \"syntax error at or near 'CURRENT_ROLE'\""],
71+
[13, 14, "latest/postgres/create_schema-12.sql", "PG13 parser fails with \"syntax error at or near 'CURRENT_ROLE'\""],
72+
[13, 14, "latest/postgres/create_schema-11.sql", "PG13 parser fails with \"syntax error at or near 'CURRENT_ROLE'\""],
73+
[13, 14, "latest/postgres/create_schema-10.sql", "PG13 parser fails with \"syntax error at or near 'CURRENT_ROLE'\""],
74+
[13, 14, "latest/postgres/create_role-83.sql", "PG13 parser fails with \"syntax error at or near 'INHERIT'\""],
75+
[13, 14, "latest/postgres/create_role-80.sql", "PG13 parser fails with \"syntax error at or near 'OPTION'\""],
76+
[13, 14, "latest/postgres/create_procedure-49.sql", "PG13 parser fails with \"syntax error at or near 'BEGIN'\""],
77+
[13, 14, "latest/postgres/create_procedure-16.sql", "PG13 parser fails with \"syntax error at or near 'BEGIN'\""],
78+
[13, 14, "latest/postgres/create_procedure-12.sql", "PG13 parser fails with \"syntax error at or near 'BEGIN'\""],
79+
[13, 14, "latest/postgres/create_index-85.sql", "PG13 parser fails with \"syntax error at or near 'NULLS'\""],
80+
[13, 14, "latest/postgres/create_index-83.sql", "PG13 parser fails with \"syntax error at or near 'NULLS'\""],
81+
[13, 14, "latest/postgres/create_index-82.sql", "PG13 parser fails with \"syntax error at or near 'NULLS'\""],
82+
[13, 14, "latest/postgres/create_index-72.sql", "PG13 parser fails with \"syntax error at or near 'NULLS'\""],
83+
[13, 14, "latest/postgres/create_index-71.sql", "PG13 parser fails with \"syntax error at or near 'NULLS'\""],
84+
[13, 14, "latest/postgres/create_index-326.sql", "PG13 parser fails with \"syntax error at or near 'CONCURRENTLY'\""],
85+
[13, 14, "latest/postgres/create_index-325.sql", "PG13 parser fails with \"syntax error at or near 'CONCURRENTLY'\""],
86+
[13, 14, "latest/postgres/create_index-210.sql", "PG13 parser fails with \"syntax error at or near 'CONCURRENTLY'\""],
87+
[13, 14, "latest/postgres/create_index-184.sql", "PG13 parser fails with \"syntax error at or near 'NULLS'\""],
88+
[13, 14, "latest/postgres/create_function_sql-98.sql", "PG13 parser fails with \"syntax error at or near 'RETURN'\""],
89+
[13, 14, "latest/postgres/create_function_sql-86.sql", "PG13 parser fails with \"syntax error at or near 'RETURN'\""],
90+
[13, 14, "latest/postgres/create_function_sql-68.sql", "PG13 parser fails with \"syntax error at or near 'BEGIN'\""],
91+
[13, 14, "latest/postgres/create_function_sql-67.sql", "PG13 parser fails with \"syntax error at or near 'RETURN'\""],
92+
[13, 14, "latest/postgres/create_function_sql-66.sql", "PG13 parser fails with \"syntax error at or near 'RETURN'\""],
93+
[13, 14, "latest/postgres/create_function_sql-65.sql", "PG13 parser fails with \"syntax error at or near 'RETURN'\""],
94+
[13, 14, "latest/postgres/create_function_sql-64.sql", "PG13 parser fails with \"syntax error at or near 'BEGIN'\""],
95+
[13, 14, "latest/postgres/create_function_sql-62.sql", "PG13 parser fails with \"syntax error at or near 'BEGIN'\""],
96+
[13, 14, "latest/postgres/create_function_sql-61.sql", "PG13 parser fails with \"syntax error at or near 'BEGIN'\""],
97+
[13, 14, "latest/postgres/create_function_sql-60.sql", "PG13 parser fails with \"syntax error at or near 'BEGIN'\""],
98+
[13, 14, "latest/postgres/create_function_sql-59.sql", "PG13 parser fails with \"syntax error at or near 'RETURN'\""],
99+
[13, 14, "latest/postgres/create_function_sql-58.sql", "PG13 parser fails with \"syntax error at or near 'RETURN'\""],
100+
[13, 14, "latest/postgres/create_function_sql-57.sql", "PG13 parser fails with \"syntax error at or near 'RETURN'\""],
101+
[13, 14, "latest/postgres/create_function_sql-121.sql", "PG13 parser fails with \"syntax error at or near 'BEGIN'\""],
102+
[13, 14, "latest/postgres/create_function_sql-100.sql", "PG13 parser fails with \"syntax error at or near 'RETURN'\""],
103+
[13, 14, "latest/postgres/create_am-96.sql", "PG13 parser fails with 'syntax error at or near 'ACCESS'"],
104+
[13, 14, "latest/postgres/create_am-94.sql", "PG13 parser fails with 'syntax error at or near 'ACCESS'"],
105+
[13, 14, "latest/postgres/create_am-90.sql", "PG13 parser fails with 'syntax error at or near 'ACCESS'"],
106+
[13, 14, "latest/postgres/create_am-86.sql", "PG13 parser fails with 'syntax error at or near 'ACCESS'"],
107+
[13, 14, "latest/postgres/create_am-75.sql", "PG13 parser fails with 'syntax error at or near 'ACCESS'"],
108+
[13, 14, "latest/postgres/create_am-74.sql", "PG13 parser fails with 'syntax error at or near 'ACCESS'"],
109+
[13, 14, "latest/postgres/create_am-73.sql", "PG13 parser fails with 'syntax error at or near 'ACCESS'"],
110+
[13, 14, "latest/postgres/create_am-70.sql", "PG13 parser fails with 'syntax error at or near 'ACCESS'"],
111+
[13, 14, "latest/postgres/create_am-65.sql", "PG13 parser fails with 'syntax error at or near 'ACCESS'"],
112+
[13, 14, "latest/postgres/create_am-62.sql", "PG13 parser fails with 'syntax error at or near 'ACCESS'"],
113+
[13, 14, "latest/postgres/create_am-57.sql", "PG13 parser fails with 'syntax error at or near 'ACCESS'"],
114+
[13, 14, "latest/postgres/create_am-55.sql", "PG13 parser fails with 'syntax error at or near 'ACCESS'"],
115+
[13, 14, "latest/postgres/create_am-53.sql", "PG13 parser fails with 'syntax error at or near 'ACCESS'"],
116+
[13, 14, "latest/postgres/create_am-112.sql", "PG13 parser fails with 'syntax error at or near 'ACCESS'"],
117+
[13, 14, "latest/postgres/create_am-109.sql", "PG13 parser fails with 'syntax error at or near 'ACCESS'"],
118+
[13, 14, "latest/postgres/create_am-106.sql", "PG13 parser fails with 'syntax error at or near 'ACCESS'"],
119+
[13, 14, "latest/postgres/create_am-104.sql", "PG13 parser fails with 'syntax error at or near 'ACCESS'"],
120+
];

0 commit comments

Comments
 (0)