diff --git a/finisher_api.go b/finisher_api.go index cc07a126..33d7a5a6 100644 --- a/finisher_api.go +++ b/finisher_api.go @@ -465,7 +465,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 { + if tx.RowsAffected != 1 { *count = tx.RowsAffected } diff --git a/tests/count_test.go b/tests/count_test.go index b71e3de5..2199dc6d 100644 --- a/tests/count_test.go +++ b/tests/count_test.go @@ -141,7 +141,7 @@ func TestCount(t *testing.T) { } DB.Create(sameUsers) - if err := DB.Model(&User{}).Where("name = ?", "count-4").Group("name").Count(&count11).Error; err != nil || count11 != 1 { + if err := DB.Model(&User{}).Where("name = ?", "count-4").Group("name").Count(&count11).Error; err != nil || count11 != int64(len(sameUsers)) { t.Fatalf("Count should be 3, but got count: %v err %v", count11, err) } diff --git a/tests/go.mod b/tests/go.mod index 9c87ca34..23fc2cad 100644 --- a/tests/go.mod +++ b/tests/go.mod @@ -6,13 +6,13 @@ require ( github.com/google/uuid v1.3.0 github.com/jinzhu/now v1.1.5 github.com/lib/pq v1.10.7 - golang.org/x/crypto v0.0.0-20221012134737-56aed061732a // indirect - golang.org/x/text v0.4.0 // indirect - gorm.io/driver/mysql v1.4.3 - gorm.io/driver/postgres v1.4.4 + github.com/mattn/go-sqlite3 v1.14.16 // indirect + golang.org/x/crypto v0.3.0 // indirect + gorm.io/driver/mysql v1.4.4 + gorm.io/driver/postgres v1.4.5 gorm.io/driver/sqlite v1.4.3 gorm.io/driver/sqlserver v1.4.1 - gorm.io/gorm v1.24.0 + gorm.io/gorm v1.24.2 ) replace gorm.io/gorm => ../