sqlparser-rs 0.60.3-rc2 → 0.60.3-rc4
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/dist/index.cjs +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
- 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-rc4` = upstream `0.60.0` + binding fix)
|
|
228
253
|
|
|
229
254
|
| This package | sqlparser-rs |
|
|
230
255
|
|--------------|--------------|
|
package/dist/index.cjs
CHANGED
|
@@ -270,7 +270,7 @@ async function initWasm() {
|
|
|
270
270
|
/* @vite-ignore */
|
|
271
271
|
wasmJsUrl.href
|
|
272
272
|
);
|
|
273
|
-
if (typeof wasm.default === "function") await wasm.default(wasmBinaryUrl);
|
|
273
|
+
if (typeof wasm.default === "function") await wasm.default({ module_or_path: wasmBinaryUrl });
|
|
274
274
|
wasmModule = wasm;
|
|
275
275
|
} catch (error) {
|
|
276
276
|
throw new WasmInitError(`Failed to load WASM module in browser: ${error instanceof Error ? error.message : String(error)}`);
|
package/dist/index.mjs
CHANGED
|
@@ -269,7 +269,7 @@ async function initWasm() {
|
|
|
269
269
|
/* @vite-ignore */
|
|
270
270
|
wasmJsUrl.href
|
|
271
271
|
);
|
|
272
|
-
if (typeof wasm.default === "function") await wasm.default(wasmBinaryUrl);
|
|
272
|
+
if (typeof wasm.default === "function") await wasm.default({ module_or_path: wasmBinaryUrl });
|
|
273
273
|
wasmModule = wasm;
|
|
274
274
|
} catch (error) {
|
|
275
275
|
throw new WasmInitError(`Failed to load WASM module in browser: ${error instanceof Error ? error.message : String(error)}`);
|
package/package.json
CHANGED
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-rc4` = 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
|