Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/node_sqlite.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2293,6 +2293,13 @@ bool StatementSync::BindValue(const Local<Value>& value, const int index) {
buf.data(),
static_cast<sqlite3_uint64>(buf.length()),
SQLITE_TRANSIENT);
} else if (value->IsArrayBuffer()) {
Local<ArrayBuffer> ab = value.As<ArrayBuffer>();
r = sqlite3_bind_blob64(statement_,
index,
ab->Data(),
static_cast<sqlite3_uint64>(ab->ByteLength()),
SQLITE_TRANSIENT);
} else if (value->IsBigInt()) {
bool lossless;
int64_t as_int = value.As<BigInt>()->Int64Value(&lossless);
Expand Down
11 changes: 11 additions & 0 deletions test/parallel/test-sqlite-data-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down