Affected URL(s)
https://nodejs.org/docs/latest/api/sqlite.html#statementsetallowbarenamedparametersenabled
Description of the problem
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 }
Affected URL(s)
https://nodejs.org/docs/latest/api/sqlite.html#statementsetallowbarenamedparametersenabled
Description of the problem
For sqlite
statement.setAllowBareNamedParameters()the docs say:but this is not right, the default value for
allowBareNamedParametersis 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 forallowBareNamedParametersdefaulting to true not false.Example showing
allowBareNamedParametersdefaults to true: