Quote the table name in CountOrphanedObjects (#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>
tokarchuk/v1.17
zeripath 3 years ago committed by GitHub
parent f5bb788c4e
commit 76a3190b8a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      models/consistency.go

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

Loading…
Cancel
Save