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

More batch delete and update #676

Merged
merged 11 commits into from
Dec 30, 2019
Merged

More batch delete and update #676

merged 11 commits into from
Dec 30, 2019

Conversation

groue
Copy link
Owner

@groue groue commented Dec 29, 2019

This pull request makes it possible to use the deleteAll and updateAll methods with more query interface requests. Generally speaking, requests that are joined, or grouped on a unique key, can now be batch deleted or updated, when previous versions of GRDB would raise a fatal error.

For example:

try dbQueue.write { db in
    // All teams without players
    let request = Team.having(Team.players.isEmpty)
    try request.deleteAll(db)
    try request.updateAll(db, Column("active") <- false)
    
    // All players whose team is inactive
    let request = Player.joining(required: Player.team.filter(Column("active") == false))
    try request.deleteAll(db)
    try request.updateAll(db, Column("score") <- 0)
}

@groue groue merged commit 1fa93ab into development Dec 30, 2019
@groue groue deleted the dev/moreDeleteAndUpdate branch December 30, 2019 12:37
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