summaryrefslogtreecommitdiffstats
path: root/models/migrate.go
diff options
context:
space:
mode:
authorAravinth Manivannan <realaravinth@batsense.net>2022-01-03 15:35:01 +0000
committerGitHub <noreply@github.com>2022-01-03 23:35:01 +0800
commitade41f3f048d71521af2c9df0ea0623c372d48a3 (patch)
tree91f530a1dd958cf169e3c32991808485ebbbdba3 /models/migrate.go
parentf499f23039a46a7b0b48ca848ead242fe430da29 (diff)
downloadgitea-ade41f3f048d71521af2c9df0ea0623c372d48a3.tar.gz
gitea-ade41f3f048d71521af2c9df0ea0623c372d48a3.zip
tests: add coverage for models migration helpers (#18162)
They were previously not covered at all, either by integration tests or unit tests. This PR also fixes a bug where the `num_comments` field was incorrectly set to include all types of comments. It sets num_closed_issues: 0 as default in milestone unit test fixtures. If they are not set, Incr("num_closed_issues") will be a noop because the field is null.
Diffstat (limited to 'models/migrate.go')
-rw-r--r--models/migrate.go2
1 files changed, 1 insertions, 1 deletions
diff --git a/models/migrate.go b/models/migrate.go
index 07d2b0f2d9..ce529efc4b 100644
--- a/models/migrate.go
+++ b/models/migrate.go
@@ -166,7 +166,7 @@ func InsertIssueComments(comments []*Comment) error {
}
for issueID := range issueIDs {
- if _, err := db.Exec(ctx, "UPDATE issue set num_comments = (SELECT count(*) FROM comment WHERE issue_id = ?) WHERE id = ?", issueID, issueID); err != nil {
+ if _, err := db.Exec(ctx, "UPDATE issue set num_comments = (SELECT count(*) FROM comment WHERE issue_id = ? AND `type`=?) WHERE id = ?", issueID, CommentTypeComment, issueID); err != nil {
return err
}
}