From 34650b925b09c432961c215b6bc80cefec14b339 Mon Sep 17 00:00:00 2001 From: zeripath Date: Sat, 30 Oct 2021 11:01:22 +0100 Subject: [PATCH] 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 --- models/consistency.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/models/consistency.go b/models/consistency.go index f037b0515704..896c07ab8d1e 100644 --- a/models/consistency.go +++ b/models/consistency.go @@ -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") }