forked from duckdb/duckdb-wasm
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test on better handling for unicode in JS-side prepared statement
- Loading branch information
Showing
2 changed files
with
38 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import * as duckdb from '../../src'; | ||
|
||
// 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); | ||
}); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters