From 76a3190b8a988e18a6b5d66dcc7324f04d83342f Mon Sep 17 00:00:00 2001 From: zeripath Date: Sat, 30 Oct 2021 10:17:40 +0100 Subject: [PATCH] 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 --- models/consistency.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/models/consistency.go b/models/consistency.go index 8af884365e..b9b590cfd4 100644 --- a/models/consistency.go +++ b/models/consistency.go @@ -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") }