Documentation correction for SQLite parameter binding default behavior.
The documentation incorrectly states that SQLite requires a prefix character for named parameters by default, when in fact the default behavior allows bare named parameters. The task involves updating the documentation to reflect the correct default behavior.
https://nodejs.org/docs/latest/api/sqlite.html#statementsetallowbarenamedparametersenabled
For sqlite statement.setAllowBareNamedParameters() the docs say:
By default, node:sqlite requires that this prefix character is present when binding parameters .. To improve ergonomics, this method can be used to also allow bare named parameters
but this is not right, the default value for allowBareNamedParameters is true, see database.prepare(sql[, options]) and new DatabaseSync(path[, options]), which means the prefix is not required. This needs to be re-written to account for allowBareNamedParameters defaulting to true not false.
Example showing allowBareNamedParameters defaults to true:
import { DatabaseSync } from 'node:sqlite';
const db = new DatabaseSync(':memory:');
db.exec('CREATE TABLE t (c1, c2, c3)');
// named parameters $c1, $c2, $c3
const insert = db.prepare('INSERT INTO t VALUES ($c1, $c2, $c3)');
// bare named parameters, prefix not required by default
insert.run({ c1: 1, c2: 2, c3: 3 });
console.log(db.prepare('SELECT * FROM t').get());
// { c1: 1, c2: 2, c3: 3 }
Claim this issue to let others know you're working on it. You'll earn 5 points when you complete it!