Skip to content

Commit

Permalink
feat(csv-issues-esm): issue 441
Browse files Browse the repository at this point in the history
  • Loading branch information
wdavidw committed Nov 7, 2024
1 parent 4819511 commit 6ecf900
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
19 changes: 19 additions & 0 deletions demo/issues-esm/lib/441.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import assert from "node:assert";
import { Database } from "duckdb-async";
import { stringify } from "csv-stringify/sync";

const db = await Database.create(":memory:");
const t = await db.all("SELECT DATE '2022-01-01' as dt");

// Validate that duckdb returns as an instance of JS date
assert(t[0].dt instanceof Date);
// Validate that date objects are handled by `cast.date`
assert.equal(stringify(t, { cast: { date: () => "ok" } }).trim(), "ok");

// First assertion raised in the issue
assert.equal(stringify(t), 1640995200000);
// Second assertion raised in the issue
assert.equal(
stringify(t, { cast: { date: (x) => x.getTime().toString() } }).trim(),
1640995200000,
);
3 changes: 2 additions & 1 deletion demo/issues-esm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"csv-parse": "^5.5.6",
"csv-stringify": "^6.5.1",
"dedent": "^1.5.3",
"desm": "^1.3.1"
"desm": "^1.3.1",
"duckdb-async": "^1.1.1"
}
}

0 comments on commit 6ecf900

Please sign in to comment.