fix generics tests for mysql
This commit is contained in:
parent
2d6d7f9485
commit
3de6d0b2f9
@ -119,6 +119,7 @@ func TestConnPoolWrapper(t *testing.T) {
|
|||||||
}()
|
}()
|
||||||
|
|
||||||
db, err := gorm.Open(mysql.New(mysql.Config{Conn: conn, DisableWithReturning: true}))
|
db, err := gorm.Open(mysql.New(mysql.Config{Conn: conn, DisableWithReturning: true}))
|
||||||
|
db.Logger = DB.Logger
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Should open db success, but got %v", err)
|
t.Fatalf("Should open db success, but got %v", err)
|
||||||
}
|
}
|
||||||
|
@ -355,7 +355,7 @@ func TestGenericsGroupHaving(t *testing.T) {
|
|||||||
t.Fatalf("CreateInBatches failed: %v", err)
|
t.Fatalf("CreateInBatches failed: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
grouped, err := gorm.G[User](DB).Where("name like ?", "GenericsGroupHaving%").Group("name").Having("COUNT(*) > ?", 1).Find(ctx)
|
grouped, err := gorm.G[User](DB).Select("name").Where("name like ?", "GenericsGroupHaving%").Group("name").Having("COUNT(id) > ?", 1).Find(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Group+Having Find failed: %v", err)
|
t.Fatalf("Group+Having Find failed: %v", err)
|
||||||
}
|
}
|
||||||
|
20
tests/go.mod
20
tests/go.mod
@ -1,15 +1,15 @@
|
|||||||
module gorm.io/gorm/tests
|
module gorm.io/gorm/tests
|
||||||
|
|
||||||
go 1.18
|
go 1.18.0
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/google/uuid v1.6.0
|
github.com/google/uuid v1.6.0
|
||||||
github.com/jinzhu/now v1.1.5
|
github.com/jinzhu/now v1.1.5
|
||||||
github.com/lib/pq v1.10.9
|
github.com/lib/pq v1.10.9
|
||||||
github.com/stretchr/testify v1.9.0
|
github.com/stretchr/testify v1.10.0
|
||||||
gorm.io/driver/mysql v1.5.7
|
gorm.io/driver/mysql v1.5.7
|
||||||
gorm.io/driver/postgres v1.5.10
|
gorm.io/driver/postgres v1.5.11
|
||||||
gorm.io/driver/sqlite v1.5.6
|
gorm.io/driver/sqlite v1.5.7
|
||||||
gorm.io/driver/sqlserver v1.5.4
|
gorm.io/driver/sqlserver v1.5.4
|
||||||
gorm.io/gorm v1.25.12
|
gorm.io/gorm v1.25.12
|
||||||
)
|
)
|
||||||
@ -17,20 +17,20 @@ require (
|
|||||||
require (
|
require (
|
||||||
filippo.io/edwards25519 v1.1.0 // indirect
|
filippo.io/edwards25519 v1.1.0 // indirect
|
||||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||||
github.com/go-sql-driver/mysql v1.8.1 // indirect
|
github.com/go-sql-driver/mysql v1.9.2 // indirect
|
||||||
github.com/golang-sql/civil v0.0.0-20220223132316-b832511892a9 // indirect
|
github.com/golang-sql/civil v0.0.0-20220223132316-b832511892a9 // indirect
|
||||||
github.com/golang-sql/sqlexp v0.1.0 // indirect
|
github.com/golang-sql/sqlexp v0.1.0 // indirect
|
||||||
github.com/jackc/pgpassfile v1.0.0 // indirect
|
github.com/jackc/pgpassfile v1.0.0 // indirect
|
||||||
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 // indirect
|
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 // indirect
|
||||||
github.com/jackc/pgx/v5 v5.7.1 // indirect
|
github.com/jackc/pgx/v5 v5.7.4 // indirect
|
||||||
github.com/jinzhu/inflection v1.0.0 // indirect
|
github.com/jinzhu/inflection v1.0.0 // indirect
|
||||||
github.com/kr/text v0.2.0 // indirect
|
github.com/kr/text v0.2.0 // indirect
|
||||||
github.com/mattn/go-sqlite3 v1.14.24 // indirect
|
github.com/mattn/go-sqlite3 v1.14.28 // indirect
|
||||||
github.com/microsoft/go-mssqldb v1.7.2 // indirect
|
github.com/microsoft/go-mssqldb v1.8.0 // indirect
|
||||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||||
github.com/rogpeppe/go-internal v1.12.0 // indirect
|
github.com/rogpeppe/go-internal v1.12.0 // indirect
|
||||||
golang.org/x/crypto v0.29.0 // indirect
|
golang.org/x/crypto v0.37.0 // indirect
|
||||||
golang.org/x/text v0.20.0 // indirect
|
golang.org/x/text v0.24.0 // indirect
|
||||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -419,7 +419,7 @@ func TestJoinsPreload_Issue7013(t *testing.T) {
|
|||||||
var entries []User
|
var entries []User
|
||||||
assert.NotPanics(t, func() {
|
assert.NotPanics(t, func() {
|
||||||
assert.NoError(t,
|
assert.NoError(t,
|
||||||
DB.Debug().Preload("Manager.Team").
|
DB.Preload("Manager.Team").
|
||||||
Joins("Manager.Company").
|
Joins("Manager.Company").
|
||||||
Find(&entries).Error)
|
Find(&entries).Error)
|
||||||
})
|
})
|
||||||
@ -456,7 +456,7 @@ func TestJoinsPreload_Issue7013_RelationEmpty(t *testing.T) {
|
|||||||
var entries []Building
|
var entries []Building
|
||||||
assert.NotPanics(t, func() {
|
assert.NotPanics(t, func() {
|
||||||
assert.NoError(t,
|
assert.NoError(t,
|
||||||
DB.Debug().Preload("Owner.Furnitures").
|
DB.Preload("Owner.Furnitures").
|
||||||
Joins("Owner.Company").
|
Joins("Owner.Company").
|
||||||
Find(&entries).Error)
|
Find(&entries).Error)
|
||||||
})
|
})
|
||||||
@ -468,7 +468,7 @@ func TestJoinsPreload_Issue7013_NoEntries(t *testing.T) {
|
|||||||
var entries []User
|
var entries []User
|
||||||
assert.NotPanics(t, func() {
|
assert.NotPanics(t, func() {
|
||||||
assert.NoError(t,
|
assert.NoError(t,
|
||||||
DB.Debug().Preload("Manager.Team").
|
DB.Preload("Manager.Team").
|
||||||
Joins("Manager.Company").
|
Joins("Manager.Company").
|
||||||
Where("1 <> 1").
|
Where("1 <> 1").
|
||||||
Find(&entries).Error)
|
Find(&entries).Error)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user