Skip to content

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

Description

@AtomicCat

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?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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