dyedgreen / deno-sqlite

Deno SQLite module
https://deno.land/x/sqlite
MIT License
409 stars 36 forks source link

Consider adding support for "IN" statements in prepared queries #208

Closed teleclimber closed 2 years ago

teleclimber commented 2 years ago

Go's sqlx has a nice helper for preparing queries with "IN" statements:

http://jmoiron.github.io/sqlx/#inQueries

This allows you to write queries like this:

db.queryEntries(`SELECT * FROM things WHERE color IN (:colors)`, {colors:["blue","yellow"]});

I looked at the code to see if I could do this but with the WASM stuff in there I quickly lost the thread.

dyedgreen commented 2 years ago

I don't think this can be supported reasonably at the level of this library.

SQLite does not have a concept of binding arrays of values, rather the IN works with an in-line literal list of values, or an existing table / nested SELECT statement. (See https://www.sqlite.org/syntax/expr.html.)

This could be implemented e.g. at the level of a query builder.