Skip to content

Commit 3842f95

Browse files
committed
errors
1 parent 3aeb472 commit 3842f95

File tree

8 files changed

+44
-81
lines changed

8 files changed

+44
-81
lines changed

full/src/index.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ export const parse = awaitInit(async (query: string): Promise<ParseResult> => {
9292
resultPtr = wasmModule._wasm_parse_query(queryPtr);
9393
const resultStr = ptrToString(resultPtr);
9494

95-
if (resultStr.startsWith('syntax error') || resultStr.startsWith('deparse error') || resultStr.includes('ERROR')) {
95+
if (resultStr.startsWith('syntax error') || resultStr.startsWith('deparse error') || resultStr.startsWith('ERROR')) {
9696
throw new Error(resultStr);
9797
}
9898

@@ -121,7 +121,7 @@ export const deparse = awaitInit(async (parseTree: ParseResult): Promise<string>
121121
resultPtr = wasmModule._wasm_deparse_protobuf(dataPtr, data.length);
122122
const resultStr = ptrToString(resultPtr);
123123

124-
if (resultStr.startsWith('syntax error') || resultStr.startsWith('deparse error') || resultStr.includes('ERROR')) {
124+
if (resultStr.startsWith('syntax error') || resultStr.startsWith('deparse error') || resultStr.startsWith('ERROR')) {
125125
throw new Error(resultStr);
126126
}
127127

@@ -142,7 +142,7 @@ export const parsePlPgSQL = awaitInit(async (query: string): Promise<ParseResult
142142
resultPtr = wasmModule._wasm_parse_plpgsql(queryPtr);
143143
const resultStr = ptrToString(resultPtr);
144144

145-
if (resultStr.startsWith('syntax error') || resultStr.startsWith('deparse error') || resultStr.includes('ERROR')) {
145+
if (resultStr.startsWith('syntax error') || resultStr.startsWith('deparse error') || resultStr.startsWith('ERROR')) {
146146
throw new Error(resultStr);
147147
}
148148

@@ -163,7 +163,7 @@ export const fingerprint = awaitInit(async (query: string): Promise<string> => {
163163
resultPtr = wasmModule._wasm_fingerprint(queryPtr);
164164
const resultStr = ptrToString(resultPtr);
165165

166-
if (resultStr.startsWith('syntax error') || resultStr.startsWith('deparse error') || resultStr.includes('ERROR')) {
166+
if (resultStr.startsWith('syntax error') || resultStr.startsWith('deparse error') || resultStr.startsWith('ERROR')) {
167167
throw new Error(resultStr);
168168
}
169169

@@ -184,7 +184,7 @@ export const normalize = awaitInit(async (query: string): Promise<string> => {
184184
resultPtr = wasmModule._wasm_normalize_query(queryPtr);
185185
const resultStr = ptrToString(resultPtr);
186186

187-
if (resultStr.startsWith('syntax error') || resultStr.startsWith('deparse error') || resultStr.includes('ERROR')) {
187+
if (resultStr.startsWith('syntax error') || resultStr.startsWith('deparse error') || resultStr.startsWith('ERROR')) {
188188
throw new Error(resultStr);
189189
}
190190

@@ -209,7 +209,7 @@ export function parseSync(query: string): ParseResult {
209209
resultPtr = wasmModule._wasm_parse_query(queryPtr);
210210
const resultStr = ptrToString(resultPtr);
211211

212-
if (resultStr.startsWith('syntax error') || resultStr.startsWith('deparse error') || resultStr.includes('ERROR')) {
212+
if (resultStr.startsWith('syntax error') || resultStr.startsWith('deparse error') || resultStr.startsWith('ERROR')) {
213213
throw new Error(resultStr);
214214
}
215215

@@ -241,7 +241,7 @@ export function deparseSync(parseTree: ParseResult): string {
241241
resultPtr = wasmModule._wasm_deparse_protobuf(dataPtr, data.length);
242242
const resultStr = ptrToString(resultPtr);
243243

244-
if (resultStr.startsWith('syntax error') || resultStr.startsWith('deparse error') || resultStr.includes('ERROR')) {
244+
if (resultStr.startsWith('syntax error') || resultStr.startsWith('deparse error') || resultStr.startsWith('ERROR')) {
245245
throw new Error(resultStr);
246246
}
247247

@@ -265,7 +265,7 @@ export function parsePlPgSQLSync(query: string): ParseResult {
265265
resultPtr = wasmModule._wasm_parse_plpgsql(queryPtr);
266266
const resultStr = ptrToString(resultPtr);
267267

268-
if (resultStr.startsWith('syntax error') || resultStr.startsWith('deparse error') || resultStr.includes('ERROR')) {
268+
if (resultStr.startsWith('syntax error') || resultStr.startsWith('deparse error') || resultStr.startsWith('ERROR')) {
269269
throw new Error(resultStr);
270270
}
271271

@@ -289,7 +289,7 @@ export function fingerprintSync(query: string): string {
289289
resultPtr = wasmModule._wasm_fingerprint(queryPtr);
290290
const resultStr = ptrToString(resultPtr);
291291

292-
if (resultStr.startsWith('syntax error') || resultStr.startsWith('deparse error') || resultStr.includes('ERROR')) {
292+
if (resultStr.startsWith('syntax error') || resultStr.startsWith('deparse error') || resultStr.startsWith('ERROR')) {
293293
throw new Error(resultStr);
294294
}
295295

@@ -313,7 +313,7 @@ export function normalizeSync(query: string): string {
313313
resultPtr = wasmModule._wasm_normalize_query(queryPtr);
314314
const resultStr = ptrToString(resultPtr);
315315

316-
if (resultStr.startsWith('syntax error') || resultStr.startsWith('deparse error') || resultStr.includes('ERROR')) {
316+
if (resultStr.startsWith('syntax error') || resultStr.startsWith('deparse error') || resultStr.startsWith('ERROR')) {
317317
throw new Error(resultStr);
318318
}
319319

@@ -334,7 +334,7 @@ export const scan = awaitInit(async (query: string): Promise<ScanResult> => {
334334
resultPtr = wasmModule._wasm_scan(queryPtr);
335335
const resultStr = ptrToString(resultPtr);
336336

337-
if (resultStr.startsWith('syntax error') || resultStr.startsWith('deparse error') || resultStr.includes('ERROR')) {
337+
if (resultStr.startsWith('syntax error') || resultStr.startsWith('deparse error') || resultStr.startsWith('ERROR')) {
338338
throw new Error(resultStr);
339339
}
340340

@@ -358,7 +358,7 @@ export function scanSync(query: string): ScanResult {
358358
resultPtr = wasmModule._wasm_scan(queryPtr);
359359
const resultStr = ptrToString(resultPtr);
360360

361-
if (resultStr.startsWith('syntax error') || resultStr.startsWith('deparse error') || resultStr.includes('ERROR')) {
361+
if (resultStr.startsWith('syntax error') || resultStr.startsWith('deparse error') || resultStr.startsWith('ERROR')) {
362362
throw new Error(resultStr);
363363
}
364364

parser/test/parser.test.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,4 +88,26 @@ describe('Parser', () => {
8888
});
8989
}
9090
});
91+
});
92+
93+
describe('Issue Test - INSERT with multiple VALUES', () => {
94+
const testSQL = "INSERT INTO logtable (message) VALUES ('Init'), ('Reboot'), ('ERROR'), ('Warning'), ('info');";
95+
const versions = [13, 14, 15, 16, 17];
96+
97+
for (const version of versions) {
98+
it(`should parse with PostgreSQL v${version} without throwing`, async () => {
99+
try {
100+
const versionModule = require(`../wasm/v${version}.cjs`);
101+
await versionModule.loadModule();
102+
const result = await versionModule.parse(testSQL);
103+
assert.ok(result); // Just verify we got a result
104+
} catch (e) {
105+
if (e.code === 'MODULE_NOT_FOUND') {
106+
console.log(`Version ${version} not available in this build`);
107+
} else {
108+
throw e;
109+
}
110+
}
111+
});
112+
}
91113
});

parser/test/parser.test.ts

Lines changed: 0 additions & 59 deletions
This file was deleted.

versions/13/src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export const parse = awaitInit(async (query: string) => {
5656
try {
5757
resultPtr = wasmModule._wasm_parse_query(queryPtr);
5858
const resultStr = ptrToString(resultPtr);
59-
if (resultStr.startsWith('syntax error') || resultStr.startsWith('deparse error') || resultStr.includes('ERROR')) {
59+
if (resultStr.startsWith('syntax error') || resultStr.startsWith('deparse error') || resultStr.startsWith('ERROR')) {
6060
throw new Error(resultStr);
6161
}
6262
return JSON.parse(resultStr);
@@ -74,7 +74,7 @@ export function parseSync(query: string) {
7474
try {
7575
resultPtr = wasmModule._wasm_parse_query(queryPtr);
7676
const resultStr = ptrToString(resultPtr);
77-
if (resultStr.startsWith('syntax error') || resultStr.startsWith('deparse error') || resultStr.includes('ERROR')) {
77+
if (resultStr.startsWith('syntax error') || resultStr.startsWith('deparse error') || resultStr.startsWith('ERROR')) {
7878
throw new Error(resultStr);
7979
}
8080
return JSON.parse(resultStr);

versions/14/src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export const parse = awaitInit(async (query: string) => {
5656
try {
5757
resultPtr = wasmModule._wasm_parse_query(queryPtr);
5858
const resultStr = ptrToString(resultPtr);
59-
if (resultStr.startsWith('syntax error') || resultStr.startsWith('deparse error') || resultStr.includes('ERROR')) {
59+
if (resultStr.startsWith('syntax error') || resultStr.startsWith('deparse error') || resultStr.startsWith('ERROR')) {
6060
throw new Error(resultStr);
6161
}
6262
return JSON.parse(resultStr);
@@ -74,7 +74,7 @@ export function parseSync(query: string) {
7474
try {
7575
resultPtr = wasmModule._wasm_parse_query(queryPtr);
7676
const resultStr = ptrToString(resultPtr);
77-
if (resultStr.startsWith('syntax error') || resultStr.startsWith('deparse error') || resultStr.includes('ERROR')) {
77+
if (resultStr.startsWith('syntax error') || resultStr.startsWith('deparse error') || resultStr.startsWith('ERROR')) {
7878
throw new Error(resultStr);
7979
}
8080
return JSON.parse(resultStr);

versions/15/src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export const parse = awaitInit(async (query: string) => {
5656
try {
5757
resultPtr = wasmModule._wasm_parse_query(queryPtr);
5858
const resultStr = ptrToString(resultPtr);
59-
if (resultStr.startsWith('syntax error') || resultStr.startsWith('deparse error') || resultStr.includes('ERROR')) {
59+
if (resultStr.startsWith('syntax error') || resultStr.startsWith('deparse error') || resultStr.startsWith('ERROR')) {
6060
throw new Error(resultStr);
6161
}
6262
return JSON.parse(resultStr);
@@ -74,7 +74,7 @@ export function parseSync(query: string) {
7474
try {
7575
resultPtr = wasmModule._wasm_parse_query(queryPtr);
7676
const resultStr = ptrToString(resultPtr);
77-
if (resultStr.startsWith('syntax error') || resultStr.startsWith('deparse error') || resultStr.includes('ERROR')) {
77+
if (resultStr.startsWith('syntax error') || resultStr.startsWith('deparse error') || resultStr.startsWith('ERROR')) {
7878
throw new Error(resultStr);
7979
}
8080
return JSON.parse(resultStr);

versions/16/src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export const parse = awaitInit(async (query: string) => {
5656
try {
5757
resultPtr = wasmModule._wasm_parse_query(queryPtr);
5858
const resultStr = ptrToString(resultPtr);
59-
if (resultStr.startsWith('syntax error') || resultStr.startsWith('deparse error') || resultStr.includes('ERROR')) {
59+
if (resultStr.startsWith('syntax error') || resultStr.startsWith('deparse error') || resultStr.startsWith('ERROR')) {
6060
throw new Error(resultStr);
6161
}
6262
return JSON.parse(resultStr);
@@ -74,7 +74,7 @@ export function parseSync(query: string) {
7474
try {
7575
resultPtr = wasmModule._wasm_parse_query(queryPtr);
7676
const resultStr = ptrToString(resultPtr);
77-
if (resultStr.startsWith('syntax error') || resultStr.startsWith('deparse error') || resultStr.includes('ERROR')) {
77+
if (resultStr.startsWith('syntax error') || resultStr.startsWith('deparse error') || resultStr.startsWith('ERROR')) {
7878
throw new Error(resultStr);
7979
}
8080
return JSON.parse(resultStr);

versions/17/src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export const parse = awaitInit(async (query: string) => {
5656
try {
5757
resultPtr = wasmModule._wasm_parse_query(queryPtr);
5858
const resultStr = ptrToString(resultPtr);
59-
if (resultStr.startsWith('syntax error') || resultStr.startsWith('deparse error') || resultStr.includes('ERROR')) {
59+
if (resultStr.startsWith('syntax error') || resultStr.startsWith('deparse error') || resultStr.startsWith('ERROR')) {
6060
throw new Error(resultStr);
6161
}
6262
return JSON.parse(resultStr);
@@ -74,7 +74,7 @@ export function parseSync(query: string) {
7474
try {
7575
resultPtr = wasmModule._wasm_parse_query(queryPtr);
7676
const resultStr = ptrToString(resultPtr);
77-
if (resultStr.startsWith('syntax error') || resultStr.startsWith('deparse error') || resultStr.includes('ERROR')) {
77+
if (resultStr.startsWith('syntax error') || resultStr.startsWith('deparse error') || resultStr.startsWith('ERROR')) {
7878
throw new Error(resultStr);
7979
}
8080
return JSON.parse(resultStr);

0 commit comments

Comments
 (0)