Problem
You can bind Buffer or TypedArray (added in #56384) but ArrayBuffer doesn't work:
import { DatabaseSync } from 'node:sqlite';
const db = new DatabaseSync(':memory:');
db.exec('create table t (c)');
const insert = db.prepare('insert into t values (?)');
insert.run(new Uint8Array([ 1, 2, 3 ]));
insert.run(new Uint16Array([ 4, 5, 6 ]));
insert.run(new Uint8Array([ 7, 8, 9 ]).buffer); // ArrayBuffer
insert.run(Buffer.from([ 10, 11, 12 ]));
console.log(db.prepare('select * from t').all());
// [
// { c: Uint8Array(3) [ 1, 2, 3 ] },
// { c: Uint8Array(6) [ 4, 0, 5, 0, 6, 0 ] },
// { c: null },
// { c: Uint8Array(3) [ 10, 11, 12 ] }
// ]
Related: Boolean should also be allowed to bind, see SQLite bind booleans
Proposal
Allow binding ArrayBuffer
Alternatives
Convert to Uint8Array or Buffer before binding, but this should not be required:
insert.run(Buffer.from(arrayBuffer));
insert.run(new Uint8Array(arrayBuffer));
Problem
You can bind
BufferorTypedArray(added in #56384) butArrayBufferdoesn't work:Related:
Booleanshould also be allowed to bind, see SQLite bind booleansProposal
Allow binding ArrayBuffer
Alternatives
Convert to Uint8Array or Buffer before binding, but this should not be required: