Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No way to query with an array of values? #34

Open
AtomicCat opened this issue Feb 4, 2020 · 0 comments
Open

No way to query with an array of values? #34

AtomicCat opened this issue Feb 4, 2020 · 0 comments

Comments

@AtomicCat
Copy link
Contributor

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant