Skip to content

Commit

Permalink
fixup! sqlite: support ArrayBuffer and TypedArray in StatementSync
Browse files Browse the repository at this point in the history
  • Loading branch information
himself65 committed Jan 2, 2025
1 parent 430743a commit 3fb606c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/node_sqlite.cc
Original file line number Diff line number Diff line change
Expand Up @@ -931,7 +931,8 @@ bool StatementSync::BindParams(const FunctionCallbackInfo<Value>& 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<Object> obj = args[0].As<Object>();
Local<Context> context = obj->GetIsolate()->GetCurrentContext();
Local<Array> keys;
Expand Down Expand Up @@ -1036,7 +1037,8 @@ bool StatementSync::BindValue(const Local<Value>& 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<uint8_t> buf(value);
r = sqlite3_bind_blob(
statement_, index, buf.data(), buf.length(), SQLITE_TRANSIENT);
Expand Down
1 change: 1 addition & 0 deletions test/parallel/test-sqlite-typed-array.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const TypedArrays = [
['Float64Array', Float64Array],
['BigInt64Array', BigInt64Array],
['BigUint64Array', BigUint64Array],
['DataView', DataView],
];

suite('StatementSync with TypedArray', () => {
Expand Down

0 comments on commit 3fb606c

Please sign in to comment.