From f48fe73e5184122be133697b8bb7f2cba465291f Mon Sep 17 00:00:00 2001 From: StounhandJ Date: Wed, 22 Oct 2025 17:01:09 +0300 Subject: [PATCH] Count always add Clause --- finisher_api.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/finisher_api.go b/finisher_api.go index e9e35f1bf..4b94f185f 100644 --- a/finisher_api.go +++ b/finisher_api.go @@ -482,6 +482,8 @@ func (db *DB) Count(count *int64) (tx *DB) { } tx.Statement.AddClause(clause.Select{Expression: expr}) + } else if strings.HasPrefix(strings.TrimSpace(strings.ToLower(tx.Statement.Selects[0])), "count(") { + tx.Statement.AddClause(clause.Select{Expression: clause.Expr{SQL: tx.Statement.Selects[0]}}) } if orderByClause, ok := db.Statement.Clauses["ORDER BY"]; ok {