We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
TryGhost
Learn more about funding links in repositories.
Report abuse
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The documentation for Database#run states:
Database#run
db.run("UPDATE tbl SET name = ?5 WHERE id = ?", { 1: 2, 5: "bar" }); This binds the first placeholder ($id) to 2 and the placeholder with index 5 to "bar".
db.run("UPDATE tbl SET name = ?5 WHERE id = ?", { 1: 2, 5: "bar" });
This binds the first placeholder ($id) to 2 and the placeholder with index 5 to "bar".
$id
2
5
"bar"
This is incorrect, to quote the sqlite documentation:
A question mark that is not followed by a number creates a parameter with a number one greater than the largest parameter number already assigned.
Therefore the ? will be parameter 6, not parameter 1.
?
Demonstration:
'use strict'; const { promisify } = require('util'); const events = require('events'); const sqlite3 = require('sqlite3'); (async () => { let db = new sqlite3.Database(':memory:'); await events.once(db, 'open'); db.get_p = promisify(db.get); console.log( await db.get_p(`SELECT ?5, ?`, { 1: 2, 5: "bar" }) ); console.log( await db.get_p(`SELECT ?5, ?`, { 6: 2, 5: "bar" }) ); console.log( await db.get_p(`SELECT ?5, ?`, 1, 2, 3, 4, 5, 6) ); })();
output:
{ '?5': 'bar', '?': null } { '?5': 'bar', '?': 2 } { '?5': 5, '?': 6 }
n/a
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Issue Summary
The documentation for
Database#run
states:This is incorrect, to quote the sqlite documentation:
Therefore the
?
will be parameter 6, not parameter 1.Steps to Reproduce
Demonstration:
output:
Version
n/a
Node.js Version
n/a
How did you install the library?
n/a
The text was updated successfully, but these errors were encountered: