File tree Expand file tree Collapse file tree 1 file changed +13
-8
lines changed
Expand file tree Collapse file tree 1 file changed +13
-8
lines changed Original file line number Diff line number Diff line change @@ -693,7 +693,7 @@ async function initializeDatabase(message: InitializeDatabaseMessage) {
693693 // Configure database options
694694 await db . open ( {
695695 query : {
696- castBigIntToDouble : true ,
696+ castBigIntToDouble : false , // Keep large integers as BigInt to preserve precision
697697 castTimestampToDate : true , // Convert timestamps to JavaScript Date objects
698698 } ,
699699 } ) ;
@@ -1410,13 +1410,18 @@ async function executeQuery(
14101410 }
14111411 // Handle other values
14121412 else {
1413- try {
1414- // Test if the value can be cloned by attempting JSON serialization
1415- JSON . stringify ( value ) ;
1416- sanitizedRow [ key ] = value ;
1417- } catch {
1418- // If value can't be serialized, convert to string
1419- sanitizedRow [ key ] = String ( value ) ;
1413+ // Handle BigInt values explicitly - convert to string to preserve precision
1414+ if ( typeof value === "bigint" ) {
1415+ sanitizedRow [ key ] = value . toString ( ) ;
1416+ } else {
1417+ try {
1418+ // Test if the value can be cloned by attempting JSON serialization
1419+ JSON . stringify ( value ) ;
1420+ sanitizedRow [ key ] = value ;
1421+ } catch {
1422+ // If value can't be serialized, convert to string
1423+ sanitizedRow [ key ] = String ( value ) ;
1424+ }
14201425 }
14211426 }
14221427 }
You can’t perform that action at this time.
0 commit comments