Skip to content

Commit

Permalink
Quote the table name in CountOrphanedObjects (go-gitea#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 go-gitea#17485

Signed-off-by: Andrew Thornton <art27@cantab.net>
  • Loading branch information
zeripath authored and Stelios Malathouras committed Mar 28, 2022
1 parent bb911aa commit 2d6f623
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 2d6f623

Please sign in to comment.