File tree Expand file tree Collapse file tree 2 files changed +21
-1
lines changed Expand file tree Collapse file tree 2 files changed +21
-1
lines changed Original file line number Diff line number Diff line change
1
+ import assert from "node:assert" ;
2
+ import { Database } from "duckdb-async" ;
3
+ import { stringify } from "csv-stringify/sync" ;
4
+
5
+ const db = await Database . create ( ":memory:" ) ;
6
+ const t = await db . all ( "SELECT DATE '2022-01-01' as dt" ) ;
7
+
8
+ // Validate that duckdb returns as an instance of JS date
9
+ assert ( t [ 0 ] . dt instanceof Date ) ;
10
+ // Validate that date objects are handled by `cast.date`
11
+ assert . equal ( stringify ( t , { cast : { date : ( ) => "ok" } } ) . trim ( ) , "ok" ) ;
12
+
13
+ // First assertion raised in the issue
14
+ assert . equal ( stringify ( t ) , 1640995200000 ) ;
15
+ // Second assertion raised in the issue
16
+ assert . equal (
17
+ stringify ( t , { cast : { date : ( x ) => x . getTime ( ) . toString ( ) } } ) . trim ( ) ,
18
+ 1640995200000 ,
19
+ ) ;
Original file line number Diff line number Diff line change 37
37
"csv-parse" : " ^5.5.6" ,
38
38
"csv-stringify" : " ^6.5.1" ,
39
39
"dedent" : " ^1.5.3" ,
40
- "desm" : " ^1.3.1"
40
+ "desm" : " ^1.3.1" ,
41
+ "duckdb-async" : " ^1.1.1"
41
42
}
42
43
}
You can’t perform that action at this time.
0 commit comments