forked from uptrace/bun
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(query): make WhereDelete compatible with ForceDelete
```go db.NewDelete().Model((*Model)(nil)).Where("1 = 1").WhereDeleted().ForceDelete().Exec(ctx) // Before this commit: DELETE FROM model WHERE 1 = 1 // After this commit: DELETE FROM model WHERE 1 = 1 AND deleted_at IS NOT NULL ``` Additionally, the `Where("1 = 1")` trick is no longer required as `WhereDeleted()` counts as a WHERE clause in mustAppendWhere. ```go db.NewDelete().Model((*Model)(nil)).WhereDeleted().ForceDelete().Exec(ctx) // Before this commit: Errors with "bun: Update and Delete queries require at least one Where" // After this commit: DELETE FROM model WHERE deleted_at IS NOT NULL ``` This gives us an easy and natural way to hard delete all soft deleted records. Fixes issue uptrace#673.
- Loading branch information
1 parent
28915f8
commit 1a6427a
Showing
3 changed files
with
39 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters