sqlparser-rs 0.60.3-rc2 → 0.60.3-rc3
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/README.md +32 -7
- package/package.json +14 -15
- package/wasm/README.md +32 -7
- package/wasm/package.json +1 -1
- package/wasm/sqlparser_rs_wasm_bg.wasm +0 -0
- package/wasm/sqlparser_rs_wasm_web_bg.wasm +0 -0
package/README.md
CHANGED
|
@@ -127,9 +127,15 @@ const ast = parse('SELECT 1');
|
|
|
127
127
|
|
|
128
128
|
### Dialects
|
|
129
129
|
|
|
130
|
-
All dialects from the upstream Rust crate are supported
|
|
130
|
+
All dialects from the upstream Rust crate are supported. You can use string names directly with `parse()`, `format()`, and `validate()`:
|
|
131
131
|
|
|
132
132
|
```typescript
|
|
133
|
+
// String names (recommended)
|
|
134
|
+
parse('SELECT 1', 'postgresql');
|
|
135
|
+
parse('SELECT 1', 'mysql');
|
|
136
|
+
parse('SELECT 1', 'bigquery');
|
|
137
|
+
|
|
138
|
+
// Or import dialect classes for type safety
|
|
133
139
|
import {
|
|
134
140
|
GenericDialect, // Permissive, accepts most SQL syntax
|
|
135
141
|
AnsiDialect, // ANSI SQL standard
|
|
@@ -144,9 +150,10 @@ import {
|
|
|
144
150
|
DuckDbDialect, // DuckDB
|
|
145
151
|
DatabricksDialect, // Databricks
|
|
146
152
|
HiveDialect, // Apache Hive
|
|
153
|
+
OracleDialect, // Oracle
|
|
147
154
|
} from 'sqlparser-rs';
|
|
148
155
|
|
|
149
|
-
// Create dialect from string
|
|
156
|
+
// Create dialect from string programmatically
|
|
150
157
|
import { dialectFromString } from 'sqlparser-rs';
|
|
151
158
|
const dialect = dialectFromString('postgresql'); // Returns PostgreSqlDialect instance
|
|
152
159
|
```
|
|
@@ -154,10 +161,10 @@ const dialect = dialectFromString('postgresql'); // Returns PostgreSqlDialect in
|
|
|
154
161
|
### Error Handling
|
|
155
162
|
|
|
156
163
|
```typescript
|
|
157
|
-
import {
|
|
164
|
+
import { parse, ParserError } from 'sqlparser-rs';
|
|
158
165
|
|
|
159
166
|
try {
|
|
160
|
-
|
|
167
|
+
parse('SELEC * FROM users');
|
|
161
168
|
} catch (error) {
|
|
162
169
|
if (error instanceof ParserError) {
|
|
163
170
|
console.log('Parse error:', error.message);
|
|
@@ -173,9 +180,10 @@ try {
|
|
|
173
180
|
Full TypeScript types are provided for the AST:
|
|
174
181
|
|
|
175
182
|
```typescript
|
|
176
|
-
import
|
|
183
|
+
import { parse } from 'sqlparser-rs';
|
|
184
|
+
import type { Statement, Query } from 'sqlparser-rs';
|
|
177
185
|
|
|
178
|
-
const statements: Statement[] =
|
|
186
|
+
const statements: Statement[] = parse('SELECT 1');
|
|
179
187
|
|
|
180
188
|
// Statement is a discriminated union type
|
|
181
189
|
for (const stmt of statements) {
|
|
@@ -188,6 +196,23 @@ for (const stmt of statements) {
|
|
|
188
196
|
}
|
|
189
197
|
```
|
|
190
198
|
|
|
199
|
+
## Bundler Configuration
|
|
200
|
+
|
|
201
|
+
### Vite
|
|
202
|
+
|
|
203
|
+
Exclude `sqlparser-rs` from dependency optimization to ensure WASM files load correctly:
|
|
204
|
+
|
|
205
|
+
```typescript
|
|
206
|
+
// vite.config.ts
|
|
207
|
+
export default defineConfig({
|
|
208
|
+
optimizeDeps: {
|
|
209
|
+
exclude: ["sqlparser-rs"],
|
|
210
|
+
},
|
|
211
|
+
});
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
This is required because Vite's pre-bundling breaks the WASM file path resolution.
|
|
215
|
+
|
|
191
216
|
## Development
|
|
192
217
|
|
|
193
218
|
### Prerequisites
|
|
@@ -224,7 +249,7 @@ npm test
|
|
|
224
249
|
This package follows the upstream [sqlparser-rs](https://github.com/apache/datafusion-sqlparser-rs) version:
|
|
225
250
|
|
|
226
251
|
- **Major.Minor** matches the upstream Rust crate version
|
|
227
|
-
- **Patch** is for TypeScript binding fixes (e.g., `0.60.3-
|
|
252
|
+
- **Patch** is for TypeScript binding fixes (e.g., `0.60.3-rc3` = upstream `0.60.0` + binding fix)
|
|
228
253
|
|
|
229
254
|
| This package | sqlparser-rs |
|
|
230
255
|
|--------------|--------------|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sqlparser-rs",
|
|
3
|
-
"version": "0.60.3-
|
|
3
|
+
"version": "0.60.3-rc3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A SQL parser for JavaScript and TypeScript, powered by datafusion-sqlparser-rs via WASM",
|
|
6
6
|
"main": "dist/index.cjs",
|
|
@@ -18,19 +18,6 @@
|
|
|
18
18
|
"wasm",
|
|
19
19
|
"README.md"
|
|
20
20
|
],
|
|
21
|
-
"scripts": {
|
|
22
|
-
"build": "npm run build:wasm && npm run build:ts",
|
|
23
|
-
"build:wasm": "cd .. && wasm-pack build --target nodejs --out-dir ts/wasm && rm -f ts/wasm/.gitignore",
|
|
24
|
-
"build:wasm:web": "cd .. && wasm-pack build --target web --out-dir ts/wasm-web",
|
|
25
|
-
"build:ts": "tsdown",
|
|
26
|
-
"test": "vitest run",
|
|
27
|
-
"test:watch": "vitest",
|
|
28
|
-
"lint": "eslint src tests",
|
|
29
|
-
"lint:fix": "eslint src tests --fix",
|
|
30
|
-
"prepublishOnly": "npm run build",
|
|
31
|
-
"local:pack": "npm run build:ts && npm pack",
|
|
32
|
-
"local:link": "npm run build:ts && npm link"
|
|
33
|
-
},
|
|
34
21
|
"keywords": [
|
|
35
22
|
"sql",
|
|
36
23
|
"parser",
|
|
@@ -58,5 +45,17 @@
|
|
|
58
45
|
},
|
|
59
46
|
"engines": {
|
|
60
47
|
"node": ">=16.0.0"
|
|
48
|
+
},
|
|
49
|
+
"scripts": {
|
|
50
|
+
"build": "npm run build:wasm && npm run build:ts",
|
|
51
|
+
"build:wasm": "cd .. && wasm-pack build --target nodejs --out-dir ts/wasm && rm -f ts/wasm/.gitignore",
|
|
52
|
+
"build:wasm:web": "cd .. && wasm-pack build --target web --out-dir ts/wasm-web",
|
|
53
|
+
"build:ts": "tsdown",
|
|
54
|
+
"test": "vitest run",
|
|
55
|
+
"test:watch": "vitest",
|
|
56
|
+
"lint": "eslint src tests",
|
|
57
|
+
"lint:fix": "eslint src tests --fix",
|
|
58
|
+
"local:pack": "npm run build:ts && npm pack",
|
|
59
|
+
"local:link": "npm run build:ts && npm link"
|
|
61
60
|
}
|
|
62
|
-
}
|
|
61
|
+
}
|
package/wasm/README.md
CHANGED
|
@@ -127,9 +127,15 @@ const ast = parse('SELECT 1');
|
|
|
127
127
|
|
|
128
128
|
### Dialects
|
|
129
129
|
|
|
130
|
-
All dialects from the upstream Rust crate are supported
|
|
130
|
+
All dialects from the upstream Rust crate are supported. You can use string names directly with `parse()`, `format()`, and `validate()`:
|
|
131
131
|
|
|
132
132
|
```typescript
|
|
133
|
+
// String names (recommended)
|
|
134
|
+
parse('SELECT 1', 'postgresql');
|
|
135
|
+
parse('SELECT 1', 'mysql');
|
|
136
|
+
parse('SELECT 1', 'bigquery');
|
|
137
|
+
|
|
138
|
+
// Or import dialect classes for type safety
|
|
133
139
|
import {
|
|
134
140
|
GenericDialect, // Permissive, accepts most SQL syntax
|
|
135
141
|
AnsiDialect, // ANSI SQL standard
|
|
@@ -144,9 +150,10 @@ import {
|
|
|
144
150
|
DuckDbDialect, // DuckDB
|
|
145
151
|
DatabricksDialect, // Databricks
|
|
146
152
|
HiveDialect, // Apache Hive
|
|
153
|
+
OracleDialect, // Oracle
|
|
147
154
|
} from 'sqlparser-rs';
|
|
148
155
|
|
|
149
|
-
// Create dialect from string
|
|
156
|
+
// Create dialect from string programmatically
|
|
150
157
|
import { dialectFromString } from 'sqlparser-rs';
|
|
151
158
|
const dialect = dialectFromString('postgresql'); // Returns PostgreSqlDialect instance
|
|
152
159
|
```
|
|
@@ -154,10 +161,10 @@ const dialect = dialectFromString('postgresql'); // Returns PostgreSqlDialect in
|
|
|
154
161
|
### Error Handling
|
|
155
162
|
|
|
156
163
|
```typescript
|
|
157
|
-
import {
|
|
164
|
+
import { parse, ParserError } from 'sqlparser-rs';
|
|
158
165
|
|
|
159
166
|
try {
|
|
160
|
-
|
|
167
|
+
parse('SELEC * FROM users');
|
|
161
168
|
} catch (error) {
|
|
162
169
|
if (error instanceof ParserError) {
|
|
163
170
|
console.log('Parse error:', error.message);
|
|
@@ -173,9 +180,10 @@ try {
|
|
|
173
180
|
Full TypeScript types are provided for the AST:
|
|
174
181
|
|
|
175
182
|
```typescript
|
|
176
|
-
import
|
|
183
|
+
import { parse } from 'sqlparser-rs';
|
|
184
|
+
import type { Statement, Query } from 'sqlparser-rs';
|
|
177
185
|
|
|
178
|
-
const statements: Statement[] =
|
|
186
|
+
const statements: Statement[] = parse('SELECT 1');
|
|
179
187
|
|
|
180
188
|
// Statement is a discriminated union type
|
|
181
189
|
for (const stmt of statements) {
|
|
@@ -188,6 +196,23 @@ for (const stmt of statements) {
|
|
|
188
196
|
}
|
|
189
197
|
```
|
|
190
198
|
|
|
199
|
+
## Bundler Configuration
|
|
200
|
+
|
|
201
|
+
### Vite
|
|
202
|
+
|
|
203
|
+
Exclude `sqlparser-rs` from dependency optimization to ensure WASM files load correctly:
|
|
204
|
+
|
|
205
|
+
```typescript
|
|
206
|
+
// vite.config.ts
|
|
207
|
+
export default defineConfig({
|
|
208
|
+
optimizeDeps: {
|
|
209
|
+
exclude: ["sqlparser-rs"],
|
|
210
|
+
},
|
|
211
|
+
});
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
This is required because Vite's pre-bundling breaks the WASM file path resolution.
|
|
215
|
+
|
|
191
216
|
## Development
|
|
192
217
|
|
|
193
218
|
### Prerequisites
|
|
@@ -224,7 +249,7 @@ npm test
|
|
|
224
249
|
This package follows the upstream [sqlparser-rs](https://github.com/apache/datafusion-sqlparser-rs) version:
|
|
225
250
|
|
|
226
251
|
- **Major.Minor** matches the upstream Rust crate version
|
|
227
|
-
- **Patch** is for TypeScript binding fixes (e.g., `0.60.3-
|
|
252
|
+
- **Patch** is for TypeScript binding fixes (e.g., `0.60.3-rc3` = upstream `0.60.0` + binding fix)
|
|
228
253
|
|
|
229
254
|
| This package | sqlparser-rs |
|
|
230
255
|
|--------------|--------------|
|
package/wasm/package.json
CHANGED
|
Binary file
|
|
Binary file
|