Skip to content

Commit

Permalink
Improve the deletion of issue (go-gitea#18945)
Browse files Browse the repository at this point in the history
Co-authored-by: 6543 <6543@obermui.de>
  • Loading branch information
2 people authored and Stelios Malathouras committed Mar 28, 2022
1 parent 5012dd3 commit f6d86d5
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions models/issue.go
Original file line number Diff line number Diff line change
Expand Up @@ -2043,17 +2043,17 @@ func deleteIssue(ctx context.Context, issue *Issue) error {
}

// delete actions assigned to this issue
var comments []int64
if err := e.Table(new(Comment)).In("issue_id", issue.ID).Cols("id").Find(&comments); err != nil {
subQuery := builder.Select("`id`").
From("`comment`").
Where(builder.Eq{"`issue_id`": issue.ID})
if _, err := e.In("comment_id", subQuery).Delete(&Action{}); err != nil {
return err
}
for i := range comments {
if _, err := e.Where("comment_id = ?", comments[i]).Delete(&Action{}); err != nil {
return err
}
}
if _, err := e.Table("action").Where("repo_id = ?", issue.RepoID).In("op_type", ActionCreateIssue, ActionCreatePullRequest).
Where("content LIKE ?", strconv.FormatInt(issue.ID, 10)+"|%").Delete(&Action{}); err != nil {

if _, err := e.Table("action").Where("repo_id = ?", issue.RepoID).
In("op_type", ActionCreateIssue, ActionCreatePullRequest).
Where("content LIKE ?", strconv.FormatInt(issue.ID, 10)+"|%").
Delete(&Action{}); err != nil {
return err
}

Expand Down

0 comments on commit f6d86d5

Please sign in to comment.