1
1
mirror of https://github.com/go-gitea/gitea synced 2024-12-25 01:54:26 +00:00

Quote the table name in CountOrphanedObjects (#17487) (#17488)

Backport #17487

CountOrphanedObjects needs to quote the table it is joining with as this table may
be `user`.

Fix #17485

Signed-off-by: Andrew Thornton <art27@cantab.net>
This commit is contained in:
zeripath 2021-10-30 11:01:22 +01:00 committed by GitHub
parent 718e0db12e
commit 34650b925b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -302,7 +302,7 @@ func DeleteOrphanedIssues() error {
// CountOrphanedObjects count subjects with have no existing refobject anymore
func CountOrphanedObjects(subject, refobject, joinCond string) (int64, error) {
return x.Table("`"+subject+"`").
Join("LEFT", refobject, joinCond).
Join("LEFT", "`"+refobject+"`", joinCond).
Where(builder.IsNull{"`" + refobject + "`.id"}).
Count("id")
}