mirror of
https://codeberg.org/davrot/forgejo.git
synced 2025-05-20 14:00:04 +02:00
Revert "[GITEA] Use join for the deleting issue actions query"
This reverts commit 9b71369be9
.
This commit is contained in:
parent
695fda3dd0
commit
d83135c204
6 changed files with 7 additions and 45 deletions
|
@ -687,21 +687,11 @@ func NotifyWatchersActions(acts []*Action) error {
|
|||
// DeleteIssueActions delete all actions related with issueID
|
||||
func DeleteIssueActions(ctx context.Context, repoID, issueID int64) error {
|
||||
// delete actions assigned to this issue
|
||||
|
||||
// MySQL doesn't use the indexes on comment_id when using a subquery.
|
||||
// It does uses the indexes when using an JOIN, however SQLite doesn't
|
||||
// allow JOINs in DELETE statements and XORM doesn't allow them as well.
|
||||
// So, an specific raw SQL query for MySQL so the query makes use of indexes.
|
||||
if setting.Database.Type.IsMySQL() {
|
||||
if _, err := db.GetEngine(ctx).Exec("DELETE action FROM action JOIN comment ON action.comment_id = comment.id WHERE comment.issue_id = ?", issueID); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
subQuery := builder.Select("`id`").From("`comment`").
|
||||
Where(builder.Eq{"`issue_id`": issueID})
|
||||
if _, err := db.GetEngine(ctx).In("comment_id", subQuery).Delete(&Action{}); err != nil {
|
||||
return err
|
||||
}
|
||||
subQuery := builder.Select("`id`").
|
||||
From("`comment`").
|
||||
Where(builder.Eq{"`issue_id`": issueID})
|
||||
if _, err := db.GetEngine(ctx).In("comment_id", subQuery).Delete(&Action{}); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
_, err := db.GetEngine(ctx).Table("action").Where("repo_id = ?", repoID).
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue