fix: count() when use group by and only find one record

This commit is contained in:
李龙 2021-11-29 11:31:57 +08:00
parent ae5bda7deb
commit cb6e71b35a

View File

@ -420,7 +420,7 @@ func (db *DB) Count(count *int64) (tx *DB) {
tx.Statement.Dest = count tx.Statement.Dest = count
tx = tx.callbacks.Query().Execute(tx) 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 *count = tx.RowsAffected
} }