Skip to content

Commit 5c56d0f

Browse files
committed
safe bigints for better-sqlite3 changeset pulling
better-sqlite3 is garbage at handling bigints. It truncates integers without warning if they are > 2^53. You can change the behavior to treat all integers as bigints but this is problematic too since not all ints are bigints. Anyway... enable this behavior for the `changes` statements where all numbers can be 2^64.
1 parent 05d7b7a commit 5c56d0f

File tree

1 file changed

+1
-0
lines changed
  • js/packages/direct-connect-nodejs/src/private

1 file changed

+1
-0
lines changed

js/packages/direct-connect-nodejs/src/private/DB.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ export default class DB {
5050
`SELECT "table", "pk", "cid", "val", "col_version", "db_version" FROM crsql_changes WHERE db_version > ? AND site_id IS NOT ?`
5151
);
5252
this.#pullChangesetStmt.raw(true);
53+
this.#pullChangesetStmt.safeIntegers(true);
5354
const applyChangesetStmt = this.db.prepare(
5455
`INSERT INTO crsql_changes ("table", "pk", "cid", "val", "col_version", "db_version", "site_id") VALUES (?, ?, ?, ?, ?, ?, ?)`
5556
);

0 commit comments

Comments
 (0)