Skip to content

Commit

Permalink
Quote the table name in CountOrphanedObjects (#17487)
Browse files Browse the repository at this point in the history
CountOrphanedObjects needs to quote the table it is joining with as this table may
be `user`.

Fix #17485

Signed-off-by: Andrew Thornton <[email protected]>
  • Loading branch information
zeripath authored Oct 30, 2021
1 parent f5bb788 commit 76a3190
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion models/consistency.go
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ func DeleteOrphanedIssues() error {
// CountOrphanedObjects count subjects with have no existing refobject anymore
func CountOrphanedObjects(subject, refobject, joinCond string) (int64, error) {
return db.GetEngine(db.DefaultContext).Table("`"+subject+"`").
Join("LEFT", refobject, joinCond).
Join("LEFT", "`"+refobject+"`", joinCond).
Where(builder.IsNull{"`" + refobject + "`.id"}).
Count("id")
}
Expand Down

0 comments on commit 76a3190

Please sign in to comment.