From 3fb606ceea99f018e4a45b125514ab4385c00bd2 Mon Sep 17 00:00:00 2001 From: Alex Yang Date: Thu, 2 Jan 2025 08:42:37 -0800 Subject: [PATCH] fixup! sqlite: support ArrayBuffer and TypedArray in `StatementSync` --- src/node_sqlite.cc | 6 ++++-- test/parallel/test-sqlite-typed-array.js | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/node_sqlite.cc b/src/node_sqlite.cc index aec055e0a5aae2..275334c9596447 100644 --- a/src/node_sqlite.cc +++ b/src/node_sqlite.cc @@ -931,7 +931,8 @@ bool StatementSync::BindParams(const FunctionCallbackInfo& args) { int anon_start = 0; if (args[0]->IsObject() && !args[0]->IsUint8Array() && - !args[0]->IsTypedArray() && !args[0]->IsArrayBuffer()) { + !args[0]->IsTypedArray() && !args[0]->IsArrayBuffer() && + !args[0]->IsDataView()) { Local obj = args[0].As(); Local context = obj->GetIsolate()->GetCurrentContext(); Local keys; @@ -1036,7 +1037,8 @@ bool StatementSync::BindValue(const Local& value, const int index) { statement_, index, *val, val.length(), SQLITE_TRANSIENT); } else if (value->IsNull()) { r = sqlite3_bind_null(statement_, index); - } else if (value->IsArrayBufferView() || value->IsArrayBuffer()) { + } else if (value->IsArrayBufferView() || value->IsArrayBuffer() || + value->IsDataView()) { ArrayBufferViewContents buf(value); r = sqlite3_bind_blob( statement_, index, buf.data(), buf.length(), SQLITE_TRANSIENT); diff --git a/test/parallel/test-sqlite-typed-array.js b/test/parallel/test-sqlite-typed-array.js index 08d42fc1033e9d..29051a1c5a3975 100644 --- a/test/parallel/test-sqlite-typed-array.js +++ b/test/parallel/test-sqlite-typed-array.js @@ -25,6 +25,7 @@ const TypedArrays = [ ['Float64Array', Float64Array], ['BigInt64Array', BigInt64Array], ['BigUint64Array', BigUint64Array], + ['DataView', DataView], ]; suite('StatementSync with TypedArray', () => {