Open
Description
From the API documentation, under 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". While this is valid in SQLite and node-sqlite3, it is not recommended to mix different placeholder types.
I tried running this as:
db.run("INSERT INTO test VALUES ('foo',2)");
db.run("UPDATE test SET name = ?5 WHERE id = ?", { 1: 2, 5: "bar"}, function(err){console.log(err)});
db.all("SELECT * FROM test", function(err, rows){console.log(rows);});
Output shows no change:
null
[ { name: 'foo', id: 2 } ]
And it seems that the second ?
is being replaced by the key numbered 6, as 5 would've been the highest assigned up to that point. Replacing { 1: 2, 5: "bar"}
with { 6: 2, 5: "bar"}
output the expected result.