Skip to content

Commit

Permalink
Issue 1467: Add test that this works in regular duckdb-wasm
Browse files Browse the repository at this point in the history
  • Loading branch information
carlopi committed Nov 1, 2023
1 parent f955138 commit fb8f8cf
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
31 changes: 31 additions & 0 deletions packages/duckdb-wasm/test/regression/github_1467.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import * as duckdb from '../../src';
import * as arrow from 'apache-arrow';

// https://github.com/duckdb/duckdb-wasm/issues/477
// Note that when ArrowJS supports negative decimals, castDecimalToDouble should probably be deprecated.
export function test1467(db: () => duckdb.AsyncDuckDB): void {
let conn: duckdb.AsyncDuckDBConnection | null = null;
beforeEach(async () => {
await db().flushFiles();
});
afterEach(async () => {
if (conn) {
await conn.close();
conn = null;
}
await db().flushFiles();
await db().dropFiles();
});
describe('GitHub issues', () => {
it('1467', async () => {
// Baseline without cast: we expect decimal values to not handle fractional parts correctly
await db().open({
path: ':memory:',
query: {},
});
conn = await db().connect();
const resultWithoutCast = await conn.query(`select substring('🦆🦆🦆' from 3) AS result;`);
expect(resultWithoutCast.toArray()[0]?.result).toEqual('🦆');
});
});
}
4 changes: 3 additions & 1 deletion packages/duckdb-wasm/test/regression/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import { test334 } from './github_334.test';
import { test393 } from './github_393.test';
import { test448 } from './github_448.test';
import { test470 } from './github_470.test';
import { test477 } from "./github_477.test";
import { test477 } from './github_477.test';
import { test1467 } from './github_1467.test';

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

0 comments on commit fb8f8cf

Please sign in to comment.