diff --git a/src/node_sqlite.cc b/src/node_sqlite.cc index fb229e19fd6aef..736c2757485c15 100644 --- a/src/node_sqlite.cc +++ b/src/node_sqlite.cc @@ -198,7 +198,8 @@ void JSValueToSQLiteResult(Isolate* isolate, } else if (value->IsString()) { Utf8Value val(isolate, value.As()); sqlite3_result_text(ctx, *val, val.length(), SQLITE_TRANSIENT); - } else if (value->IsArrayBufferView()) { + } else if (value->IsArrayBufferView() || value->IsArrayBuffer() || + value->IsSharedArrayBuffer()) { ArrayBufferViewContents buf(value); sqlite3_result_blob(ctx, buf.data(), buf.length(), SQLITE_TRANSIENT); } else if (value->IsBigInt()) { @@ -2286,7 +2287,8 @@ bool StatementSync::BindValue(const Local& value, const int index) { } } else if (value->IsNull()) { r = sqlite3_bind_null(statement_, index); - } else if (value->IsArrayBufferView()) { + } else if (value->IsArrayBufferView() || value->IsArrayBuffer() || + value->IsSharedArrayBuffer()) { ArrayBufferViewContents buf(value); r = sqlite3_bind_blob64(statement_, index, diff --git a/test/parallel/test-sqlite-data-types.js b/test/parallel/test-sqlite-data-types.js index 26af15a777d234..c8786696e335f5 100644 --- a/test/parallel/test-sqlite-data-types.js +++ b/test/parallel/test-sqlite-data-types.js @@ -80,6 +80,17 @@ suite('data binding and mapping', () => { text: '', buf: new Uint8Array(), }); + + const uint8Array = new Uint8Array([ 49, 50, 51, 52 ]); + const arrayBuffer = uint8Array.buffer; + t.assert.deepStrictEqual( + stmt.run(5, null, null, null, arrayBuffer), + { changes: 1, lastInsertRowid: 5 } + ); + t.assert.deepStrictEqual( + query.get(5), + { __proto__: null, key: 5, int: null, double: null, text: null, buf: uint8Array } + ); }); test('large strings are bound correctly', (t) => {