Skip to content

Unhandled null parameters #116

Closed
Closed
@jooadam

Description

@jooadam
var sqlite = require('sqlite3').verbose();
var db = new sqlite.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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions