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

The filter method CAN be renamed to where #571

Closed
Evertt opened this issue Dec 21, 2016 · 4 comments
Closed

The filter method CAN be renamed to where #571

Evertt opened this issue Dec 21, 2016 · 4 comments

Comments

@Evertt
Copy link

Evertt commented Dec 21, 2016

First of all I want to say, what an awesome library. I love being able to communicate with an SQLite database in a type-safe way.

So let's get to the point. In the docs you say you called the query method used for the WHERE clause in a query filter, because where was a reserved name. iIf you write the function like this:

extension QueryType {
    public func `where`(_ predicate: Expression<Bool?>) -> Self {
        var query = self
        query.clauses.filters = query.clauses.filters.map { $0 && predicate } ?? predicate
        return query
    }
}

You can actually use it like: users.where(id == 1).

@jberkel
Copy link
Collaborator

jberkel commented Dec 21, 2016

Thanks for the hint. My guess is that at the point the code was written keyword quoting was not available in the particular version of Swift.

@nhunghuynhthihong
Copy link

@jberkel it is not single quote ' , it is `.

@jberkel
Copy link
Collaborator

jberkel commented Dec 21, 2016

@nhunghuynhthihong yes, I was just referring to "quoting" in a more general sense of the term.

@jberkel
Copy link
Collaborator

jberkel commented Dec 21, 2016

#572

@jberkel jberkel closed this as completed Dec 21, 2016
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

3 participants