summaryrefslogtreecommitdiffstats
path: root/models
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2022-03-03 01:38:56 +0800
committerGitHub <noreply@github.com>2022-03-02 18:38:56 +0100
commit04971c33a3daef4e249afbcbfc0a24901669222a (patch)
tree8485904b6e0dae7913cbf74fedf77d3ee38288a3 /models
parentf8898c30dc028e8bddadffacbd357c76b0c3506b (diff)
downloadgitea-04971c33a3daef4e249afbcbfc0a24901669222a.tar.gz
gitea-04971c33a3daef4e249afbcbfc0a24901669222a.zip
Improve the deletion of issue (#18945)
Co-authored-by: 6543 <6543@obermui.de>
Diffstat (limited to 'models')
-rw-r--r--models/issue.go18
1 files changed, 9 insertions, 9 deletions
diff --git a/models/issue.go b/models/issue.go
index 625374faaf..fd59ac0a4b 100644
--- a/models/issue.go
+++ b/models/issue.go
@@ -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
}