From a0bddccfe168b7746a464d4769dc3f7d70f831bb Mon Sep 17 00:00:00 2001 From: Tony <63030915+tonytony2020@users.noreply.github.com> Date: Fri, 11 Jun 2021 21:51:18 +0800 Subject: [PATCH] Use count(*) instead of count(1) include NULL and non-NULL rows(SQL-92). (#4453) --- finisher_api.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/finisher_api.go b/finisher_api.go index f4fa5c76..771fa153 100644 --- a/finisher_api.go +++ b/finisher_api.go @@ -383,9 +383,9 @@ func (db *DB) Count(count *int64) (tx *DB) { } if len(tx.Statement.Selects) == 0 { - tx.Statement.AddClause(clause.Select{Expression: clause.Expr{SQL: "count(1)"}}) + tx.Statement.AddClause(clause.Select{Expression: clause.Expr{SQL: "count(*)"}}) } else if !strings.HasPrefix(strings.TrimSpace(strings.ToLower(tx.Statement.Selects[0])), "count(") { - expr := clause.Expr{SQL: "count(1)"} + expr := clause.Expr{SQL: "count(*)"} if len(tx.Statement.Selects) == 1 { dbName := tx.Statement.Selects[0]