Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix count bug #19850

Merged
merged 3 commits into from
Jun 1, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions models/consistency.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ func CountOrphanedIssues() (int64, error) {
return db.GetEngine(db.DefaultContext).Table("issue").
Join("LEFT", "repository", "issue.repo_id=repository.id").
Where(builder.IsNull{"repository.id"}).
Count("id")
Select("COUNT(`issue`.`id`)").
Count()
}

// DeleteOrphanedIssues delete issues without a repo
Expand Down Expand Up @@ -140,8 +141,9 @@ func DeleteOrphanedIssues() error {
func CountOrphanedObjects(subject, refobject, joinCond string) (int64, error) {
return db.GetEngine(db.DefaultContext).Table("`"+subject+"`").
Join("LEFT", "`"+refobject+"`", joinCond).
Where(builder.IsNull{"`" + refobject + "`.id"}).
Count("id")
Where(builder.IsNull{"`" + refobject + "`.`id`"}).
Select("COUNT(`" + subject + "`.`id`)").
Count()
}

// DeleteOrphanedObjects delete subjects with have no existing refobject anymore
Expand Down Expand Up @@ -241,7 +243,6 @@ func FixIssueLabelWithOutsideLabels() (int64, error) {
WHERE
(label.org_id = 0 AND issue.repo_id != label.repo_id) OR (label.repo_id = 0 AND label.org_id != repository.owner_id)
) AS il_too )`)

if err != nil {
return 0, err
}
Expand Down