Skip to content

Commit

Permalink
fix(ext/node): Fix handling of sqlite large integers (#28193)
Browse files Browse the repository at this point in the history
Use `v8::Number` instead of `v8::Integer` to handle > i32::MAX.

Fixes #28187
  • Loading branch information
littledivy authored Feb 20, 2025
1 parent 64abe90 commit 664d50f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion ext/node/ops/sqlite/statement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ impl StatementSync {
if self.use_big_ints.get() {
v8::BigInt::new_from_i64(scope, value).into()
} else if value.abs() <= MAX_SAFE_JS_INTEGER {
v8::Integer::new(scope, value as _).into()
v8::Number::new(scope, value as f64).into()
} else {
return Err(SqliteError::NumberTooLarge(index, value));
}
Expand Down
8 changes: 8 additions & 0 deletions tests/unit_node/sqlite_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,3 +236,11 @@ Deno.test("[node/sqlite] StatementSync#iterate", () => {

db.close();
});

// https://github.com/denoland/deno/issues/28187
Deno.test("[node/sqlite] StatementSync for large integers", () => {
const db = new DatabaseSync(":memory:");
const result = db.prepare("SELECT 2147483648").get();
assertEquals(result, { "2147483648": 2147483648, __proto__: null });
db.close();
});

0 comments on commit 664d50f

Please sign in to comment.