-
-
Notifications
You must be signed in to change notification settings - Fork 34.4k
Open
Labels
feature requestIssues that request new features to be added to Node.js.Issues that request new features to be added to Node.js.sqliteIssues and PRs related to the SQLite subsystem.Issues and PRs related to the SQLite subsystem.
Description
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 (?)');
const select = db.prepare('select * from t');
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(select.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, either by directly handling ArrayBuffer if possible, or internally converting to Uint8Array if needed
insert.run(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));jlarmstrongiv
Metadata
Metadata
Assignees
Labels
feature requestIssues that request new features to be added to Node.js.Issues that request new features to be added to Node.js.sqliteIssues and PRs related to the SQLite subsystem.Issues and PRs related to the SQLite subsystem.
Type
Projects
Status
Awaiting Triage