-
-
Notifications
You must be signed in to change notification settings - Fork 402
New issue
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
Error "Too many parameter values were provided" when using bind parameter syntax ?1, ?2 #576
Comments
|
I see! So for the |
I'm pretty sure the intent in sqlite is that the binding behavior for |
First of all I had never heard of
Quoting: https://sqlite.org/c3ref/bind_parameter_count.html
I believe that this just works by accident in better-sqlite3. Because it doesn't work when skipping indexes, which is totally valid. I think it should be possible to use both array and object syntax in this case. Otherwise you'd have to do this (which should work in my opinion, it's as ugly as the SQL itself): const stmt = database.prepare('select ?10 + ?20');
console.log(stmt.get([, , , , , , , , , , , , , , , , , , , , 10, , , , , , , , , , , , , , , , , , , , 20])); So maybe @DanielSWolf you want to reopen this as a feature request to explicitly support
No mention of |
If someone wants to make a PR, relevant places seem to be and |
My use case is straight-froward. I'd like these 2 statements to polymorphically accept the same set of parameters: const insert = db.prepare('insert into T(name, version) values(?, ?)')
const update = db.prepare('update T set version=?2 where name=?1') then some independent code that receives one of those can just call
|
@spazmodius thanks for the example. To me this looks fragile, is there a reason you cannot use |
Just preference. What you suggest is exactly what I ended up doing after realizing that |
According to the SQLite documentation, there are five different ways of referencing bind parameters in an SQL statement:
?, ?
?1, ?2
:first, :second
@first, @second
$first, $second
It seems that
better-sqlite3
supports the 1st and 5th syntax, but not the 2nd one:The last statement throws the following error:
Is there any chance of getting this syntax to work?
The text was updated successfully, but these errors were encountered: