@@ -4,6 +4,7 @@ import {mkdir, writeFile} from "node:fs/promises";
4
4
import { dirname , join } from "node:path" ;
5
5
import { parseArgs } from "node:util" ;
6
6
import { getDatabase , getDatabaseConfig , getQueryCachePath } from "../src/databases/index.js" ;
7
+ import { getReplacer } from "../src/databases/index.js" ;
7
8
8
9
if ( process . argv [ 1 ] === import . meta. filename ) run ( ) ;
9
10
@@ -52,20 +53,14 @@ export default async function run(args?: string[]): Promise<void> {
52
53
const database = await getDatabase ( config ) ;
53
54
const results = await database . call ( null , strings , ...params ) ;
54
55
await mkdir ( dirname ( cachePath ) , { recursive : true } ) ;
55
- await writeFile ( cachePath , JSON . stringify ( results , replace ) ) ;
56
+ await writeFile ( cachePath , JSON . stringify ( results , await getReplacer ( config ) ) ) ;
56
57
console . log ( join ( values . root , cachePath ) ) ;
57
58
} catch ( error ) {
58
59
console . error ( getErrorMessage ( error ) ) ;
59
60
process . exit ( 1 ) ;
60
61
}
61
62
}
62
63
63
- // Force dates to be serialized as ISO 8601 UTC, undoing this:
64
- // https://github.com/snowflakedb/snowflake-connector-nodejs/blob/a9174fb7/lib/connection/result/sf_timestamp.js#L177-L179
65
- function replace ( this : { [ key : string ] : unknown } , key : string , value : unknown ) : unknown {
66
- return this [ key ] instanceof Date ? Date . prototype . toJSON . call ( this [ key ] ) : value ;
67
- }
68
-
69
64
function getErrorMessage ( error : unknown ) : string {
70
65
return error instanceof Error &&
71
66
"errors" in error && // AggregateError
0 commit comments