You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jul 1, 2026. It is now read-only.
Repository navigation
This repository was archived by the owner on Jul 1, 2026. It is now read-only.
varsqlite=require('sqlite3').verbose();vardb=newsqlite.Database('test.db');db.all('SELECT * FROM test',null,function(error,rows){if(error){console.log(error);}else{rows.forEach(function(row){console.log(row);});}});db.close();
The previous code will produce the following output:
{ [Error: SQLITE_RANGE: bind or column index out of range] errno: 25, code: 'SQLITE_RANGE' }
Changing the second argument of Database#all() from null to [] produces the desired output.
This handling of null values is both counterintuitive and undocumented. Other methods may be affected too.
Why are you passing a null value in the first place? This behavior is sort of intended; all parameters after the SQL query and before the callback functions are added as parameters to the query. Since your query doesn't have any parameters, you get this error. Using [] is an alternative syntax to passing the parameters directly and [null] will fail in a similar way. It doesn't matter what value you pass; db.all('SELECT * FROM test', 'test')` fails with the same error.
I see now. I for one never really liked the idea of variable length argument lists, and it seemed natural to pass a null for the bind values. Actually, even the formal parameter list in the docs isn’t clear on this since the comma is outside of the brackets. It would be nice to state explicitly in the description that everything before the callback will be treated as bind values.
The previous code will produce the following output:
Changing the second argument of
Database#all()fromnullto[]produces the desired output.This handling of null values is both counterintuitive and undocumented. Other methods may be affected too.