diff --git a/tests/go.mod b/tests/go.mod index 955bafe2..c467f34b 100644 --- a/tests/go.mod +++ b/tests/go.mod @@ -6,10 +6,10 @@ require ( github.com/google/uuid v1.1.1 github.com/jinzhu/now v1.1.1 github.com/lib/pq v1.6.0 - gorm.io/driver/mysql v0.2.6 - gorm.io/driver/postgres v0.2.3 - gorm.io/driver/sqlite v1.0.7 - gorm.io/driver/sqlserver v0.2.3 + gorm.io/driver/mysql v0.2.7 + gorm.io/driver/postgres v0.2.4 + gorm.io/driver/sqlite v1.0.8 + gorm.io/driver/sqlserver v0.2.4 gorm.io/gorm v0.2.9 ) diff --git a/tests/group_by_test.go b/tests/group_by_test.go index b08f48f1..6d0ed39c 100644 --- a/tests/group_by_test.go +++ b/tests/group_by_test.go @@ -51,6 +51,14 @@ func TestGroupBy(t *testing.T) { t.Errorf("name should be groupby, but got %v, total should be 60, but got %v", name, total) } + if err := DB.Model(&User{}).Select("name, sum(age)").Where("name = ?", "groupby").Group("users.name").Row().Scan(&name, &total); err != nil { + t.Errorf("no error should happen, but got %v", err) + } + + if name != "groupby" || total != 60 { + t.Errorf("name should be groupby, but got %v, total should be 60, but got %v", name, total) + } + if err := DB.Model(&User{}).Select("name, sum(age) as total").Where("name LIKE ?", "groupby%").Group("name").Having("name = ?", "groupby1").Row().Scan(&name, &total); err != nil { t.Errorf("no error should happen, but got %v", err) }