Skip to content

Commit 3fb606c

Browse files
committed
fixup! sqlite: support ArrayBuffer and TypedArray in StatementSync
1 parent 430743a commit 3fb606c

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

src/node_sqlite.cc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -931,7 +931,8 @@ bool StatementSync::BindParams(const FunctionCallbackInfo<Value>& args) {
931931
int anon_start = 0;
932932

933933
if (args[0]->IsObject() && !args[0]->IsUint8Array() &&
934-
!args[0]->IsTypedArray() && !args[0]->IsArrayBuffer()) {
934+
!args[0]->IsTypedArray() && !args[0]->IsArrayBuffer() &&
935+
!args[0]->IsDataView()) {
935936
Local<Object> obj = args[0].As<Object>();
936937
Local<Context> context = obj->GetIsolate()->GetCurrentContext();
937938
Local<Array> keys;
@@ -1036,7 +1037,8 @@ bool StatementSync::BindValue(const Local<Value>& value, const int index) {
10361037
statement_, index, *val, val.length(), SQLITE_TRANSIENT);
10371038
} else if (value->IsNull()) {
10381039
r = sqlite3_bind_null(statement_, index);
1039-
} else if (value->IsArrayBufferView() || value->IsArrayBuffer()) {
1040+
} else if (value->IsArrayBufferView() || value->IsArrayBuffer() ||
1041+
value->IsDataView()) {
10401042
ArrayBufferViewContents<uint8_t> buf(value);
10411043
r = sqlite3_bind_blob(
10421044
statement_, index, buf.data(), buf.length(), SQLITE_TRANSIENT);

test/parallel/test-sqlite-typed-array.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ const TypedArrays = [
2525
['Float64Array', Float64Array],
2626
['BigInt64Array', BigInt64Array],
2727
['BigUint64Array', BigUint64Array],
28+
['DataView', DataView],
2829
];
2930

3031
suite('StatementSync with TypedArray', () => {

0 commit comments

Comments
 (0)