Skip to content

Add special handling for SQL IN operator in DatabaseSync for queries #57102

Closed as not planned
@mydoghasfleas

Description

@mydoghasfleas

What is the problem this feature will solve?

Being able to use the SQL IN operator is not possible without a workaround; see https://stackoverflow.com/questions/79441096/using-sql-in-operator-with-databasesync-in-node-sqlite

What is the feature you are proposing to solve the problem?

Being able to do a query like this, where parameters to an IN operator in the WHERE clause can be substituted by an array of values:

const stmt = conn.prepare(`select name from people where id in (?)`);
res = stmt.get([100,200,300])

What alternatives have you considered?

Only the workaround in the above linked Stackoverflow question, where you have to make provision for each value individually in the query (which would require a new prepared statement each time):

const values = [100,200,300];

// 3 values, so need 3 params: ?,?,?
const params = values.map(_=>'?').join(',');

const stmt = conn.prepare(`select name from people where id in (${params})`);
res = stmt.get(values);

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature requestIssues that request new features to be added to Node.js.

    Type

    No type

    Projects

    Status

    Awaiting Triage

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions