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

Enhancements to logical operators #336

Merged
merged 4 commits into from
Apr 21, 2018
Merged

Conversation

groue
Copy link
Owner

@groue groue commented Apr 21, 2018

The joined(operator:) method lets you join several conditions with the AND or OR SQL operators:

// SELECT * FROM players
// WHERE (registered
//        AND (score >= 1000)
//        AND (name IS NOT NULL))
let conditions = [
    Column("registered"),
    Column("score") >= 1000,
    Column("name") != nil]
Player.filter(conditions.joined(operator: .and))

When the sequence is empty, joined(operator: .and) returns true, and joined(operator: .or) returns false:

// SELECT * FROM players WHERE 1
Player.filter([].joined(operator: .and))

// SELECT * FROM players WHERE 0
Player.filter([].joined(operator: .or))

@groue groue added enhancement blocked Progress is impossible due to some external blocking reason labels Apr 21, 2018
@groue groue added this to the GRDB 3.0 milestone Apr 21, 2018
@groue groue mentioned this pull request Apr 21, 2018
29 tasks
@groue groue removed the blocked Progress is impossible due to some external blocking reason label Apr 21, 2018
@groue groue merged commit e44249b into GRDB3 Apr 21, 2018
@groue groue deleted the GRDB3-LogicalOperatorRefactoring branch April 21, 2018 17:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant