From 008738058fe707fc7965e0255f658dcf84e485ab Mon Sep 17 00:00:00 2001 From: Divy Srivastava Date: Sat, 14 Dec 2024 13:16:15 +0530 Subject: [PATCH] setReadBigints --- ext/node/ops/sqlite/database.rs | 2 ++ ext/node/ops/sqlite/statement.rs | 14 +++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/ext/node/ops/sqlite/database.rs b/ext/node/ops/sqlite/database.rs index 7326ad1382..3c0b81962f 100644 --- a/ext/node/ops/sqlite/database.rs +++ b/ext/node/ops/sqlite/database.rs @@ -1,5 +1,6 @@ // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. +use std::cell::Cell; use std::cell::RefCell; use std::rc::Rc; @@ -155,6 +156,7 @@ impl DatabaseSync { Ok(StatementSync { inner: raw_stmt, db: self.conn.clone(), + use_big_ints: Cell::new(false), }) } } diff --git a/ext/node/ops/sqlite/statement.rs b/ext/node/ops/sqlite/statement.rs index 4312fdf3ce..c579f65ccd 100644 --- a/ext/node/ops/sqlite/statement.rs +++ b/ext/node/ops/sqlite/statement.rs @@ -1,6 +1,7 @@ // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. use std::borrow::Cow; +use std::cell::Cell; use std::cell::RefCell; use std::rc::Rc; @@ -22,6 +23,8 @@ pub struct RunStatementResult { pub struct StatementSync { pub inner: *mut ffi::sqlite3_stmt, pub db: Rc>>, + + pub use_big_ints: Cell, } impl Drop for StatementSync { @@ -118,7 +121,11 @@ impl StatementSync { match ffi::sqlite3_column_type(self.inner, index) { ffi::SQLITE_INTEGER => { let value = ffi::sqlite3_column_int64(self.inner, index); - v8::Integer::new(scope, value as _).into() + if self.use_big_ints.get() { + v8::BigInt::new_from_i64(scope, value).into() + } else { + v8::Integer::new(scope, value as _).into() + } } ffi::SQLITE_FLOAT => { let value = ffi::sqlite3_column_double(self.inner, index); @@ -321,4 +328,9 @@ impl StatementSync { let arr = v8::Array::new_with_elements(scope, &arr); Ok(arr) } + + #[fast] + fn set_read_big_ints(&self, enabled: bool) { + self.use_big_ints.set(enabled); + } }