From cb6e71b35a771ae7e9abf21c99015f718787eb99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=BE=99?= Date: Mon, 29 Nov 2021 11:31:57 +0800 Subject: [PATCH] fix: count() when use `group by` and only find one record --- finisher_api.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/finisher_api.go b/finisher_api.go index aac3693a..207017f4 100644 --- a/finisher_api.go +++ b/finisher_api.go @@ -420,7 +420,7 @@ func (db *DB) Count(count *int64) (tx *DB) { tx.Statement.Dest = count tx = tx.callbacks.Query().Execute(tx) - if _, ok := db.Statement.Clauses["GROUP BY"]; (ok && tx.RowsAffected == 1) || tx.RowsAffected != 1 { + if _, ok := db.Statement.Clauses["GROUP BY"]; ok || tx.RowsAffected != 1 { *count = tx.RowsAffected }