Skip to content

Commit

Permalink
Add test on better handling for unicode in JS-side prepared statement
Browse files Browse the repository at this point in the history
  • Loading branch information
carlopi committed Aug 21, 2024
1 parent d170b76 commit 712c912
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
37 changes: 37 additions & 0 deletions packages/duckdb-wasm/test/regression/github_1833.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import * as duckdb from '../../src';
import * as arrow from 'apache-arrow';

// https://github.com/duckdb/duckdb-wasm/issues/1833
export function test1833(db: () => duckdb.AsyncDuckDB): void {
let conn: duckdb.AsyncDuckDBConnection;
beforeEach(async () => {
await db().flushFiles();
conn = await db().connect();
});
afterEach(async () => {
await conn.close();
await db().flushFiles();
await db().dropFiles();
});
describe('GitHub issues', () => {
it('1833', async () => {
await conn.query(`
CREATE TABLE "Test" (value VARCHAR)
`);
const stmt = await conn.prepare(`
INSERT INTO "Test" (value)
VALUES (?)
`);
await stmt.query('🦆🦆🦆🦆🦆');
await stmt.query('goo␀se');
await stmt.query('goo\u0000se');
const result = await conn.query(`
SELECT * FROM "Test"
`);
expect(result.schema.fields.length).toBe(1);
expect(result.schema.fields[0].name).toBe('value');
expect(result.toArray().length).toEqual(3);
expect(result.toArray()[2].value.length).toEqual(6);
});
});
}
2 changes: 2 additions & 0 deletions packages/duckdb-wasm/test/regression/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { test448 } from './github_448.test';
import { test470 } from './github_470.test';
import { test477 } from './github_477.test';
import { test1467 } from './github_1467.test';
import { test1833 } from './github_1833.test';

export function testRegressionAsync(adb: () => duckdb.AsyncDuckDB): void {
test332(adb);
Expand All @@ -15,4 +16,5 @@ export function testRegressionAsync(adb: () => duckdb.AsyncDuckDB): void {
test470(adb);
test477(adb);
test1467(adb);
test1833(adb);
}

0 comments on commit 712c912

Please sign in to comment.