Repository: denoland/deno
Pull request: fix(ext/node): `sqlite`'s `StatementSync` compatibility

Allows https://github.com/nodejs/node/blame/v24.12.0/test/parallel/test-sqlite-statement-sync.js to pass

Changed files:
filename: ext/node/ops/sqlite/mod.rs
patch: @@ -98,11 +98,9 @@ pub enum SqliteError {
   #[property("code" = self.code())]
   InvalidExpandedSql,
   #[class(range)]
-  #[error(
-    "The value of column {0} is too large to be represented as a JavaScript number: {1}"
-  )]
+  #[error("Value is too large to be represented as a JavaScript number: {0}")]
   #[property("code" = self.code())]
-  NumberTooLarge(i32, i64),
+  NumberTooLarge(i64),
   #[class(type)]
   #[error("Invalid callback: {0}")]
   #[property("code" = self.code())]
@@ -183,7 +181,7 @@ impl SqliteError {
       | Self::InUse
       | Self::AlreadyOpen
       | Self::StatementFinalized => ErrorCode::ERR_INVALID_STATE,
-      Self::NumberTooLarge(_, _) => ErrorCode::ERR_OUT_OF_RANGE,
+      Self::NumberTooLarge(_) => ErrorCode::ERR_OUT_OF_RANGE,
       Self::LoadExensionFailed(_) => ErrorCode::ERR_LOAD_SQLITE_EXTENSION,
       _ => ErrorCode::ERR_SQLITE_ERROR,
     }

filename: ext/node/ops/sqlite/statement.rs
patch: @@ -273,7 +273,7 @@ impl StatementSync {
           } else if value.abs() <= MAX_SAFE_JS_INTEGER {
             v8::Number::new(scope, value as f64).into()
           } else {
-            return Err(SqliteError::NumberTooLarge(index, value));
+            return Err(SqliteError::NumberTooLarge(value));
           }
         }
         ffi::SQLITE_FLOAT => {
@@ -713,10 +713,8 @@ impl StatementSync {
       ];
 
       if statement.is_iter_finished.get() {
-        let values = &[
-          v8::Boolean::new(scope, true).into(),
-          v8::undefined(scope).into(),
-        ];
+        let values =
+          &[v8::Boolean::new(scope, true).into(), v8::null(scope).into()];
         let null = v8::null(scope).into();
         let result =
           v8::Object::with_prototype_and_properties(scope, null, names, values);
@@ -728,10 +726,8 @@ impl StatementSync {
         let _ = statement.reset();
         statement.is_iter_finished.set(true);
 
-        let values = &[
-          v8::Boolean::new(scope, true).into(),
-          v8::undefined(scope).into(),
-        ];
+        let values =
+          &[v8::Boolean::new(scope, true).into(), v8::null(scope).into()];
         let null = v8::null(scope).into();
         let result =
           v8::Object::with_prototype_and_properties(scope, null, names, values);
@@ -761,10 +757,8 @@ impl StatementSync {
         DONE.v8_string(scope).unwrap().into(),
         VALUE.v8_string(scope).unwrap().into(),
       ];
-      let values = &[
-        v8::Boolean::new(scope, true).into(),
-        v8::undefined(scope).into(),
-      ];
+      let values =
+        &[v8::Boolean::new(scope, true).into(), v8::null(scope).into()];
 
       let null = v8::null(scope).into();
       let result =

filename: tests/node_compat/config.jsonc
patch: @@ -1101,6 +1101,7 @@
       "flaky": true
     },
     "parallel/test-sqlite-statement-sync-columns.js": {},
+    "parallel/test-sqlite-statement-sync.js": {},
     "parallel/test-sqlite-timeout.js": {},
     "parallel/test-sqlite-transactions.js": {},
     "parallel/test-sqlite-typed-array-and-data-view.js": {},

filename: tests/unit_node/sqlite_test.ts
patch: @@ -323,7 +323,7 @@ Deno.test("[node/sqlite] StatementSync#iterate", () => {
 
   const { done, value } = iter.next();
   assertEquals(done, true);
-  assertEquals(value, undefined);
+  assertEquals(value, null);
 
   db.close();
 });