SQift icon indicating copy to clipboard operation
SQift copied to clipboard

No way to query with an array of values?

Open AtomicCat opened this issue 4 years ago • 0 comments

There does not appear to be a (convenient) way to execute a query with an array of values. For example, I want to run a query like:

SELECT key, createDate, lastAccessDate, value FROM cache WHERE key IN ("111", "222", "333"...

Placing a ? inside the parens and passing the array as an extra argument to query seems to yield an error.

I've worked around this with code like the following:

let keyString = keys.map({ "\"\($0)\"" }).joined(separator: ", ")
let sql = "SELECT key, createDate, lastAccessDate, value FROM cache WHERE key IN (\(keyString))"
let items: [Item] = try connection.query(sql)

Is there a better way of doing this that is not documented? Would it be possible to add this capability to SQift?

AtomicCat avatar Feb 04 '20 20:02 AtomicCat