fix tests for mysql 9.0

This commit is contained in:
Jinzhu 2025-06-05 19:34:13 +08:00
parent 49b01a3e93
commit 718eae4fdd
4 changed files with 11 additions and 7 deletions

View File

@ -1,6 +1,6 @@
services:
mysql:
image: 'mysql/mysql-server:latest'
image: 'mysql:latest'
ports:
- "127.0.0.1:9910:3306"
environment:

View File

@ -7,9 +7,9 @@ require (
github.com/jinzhu/now v1.1.5
github.com/lib/pq v1.10.9
github.com/stretchr/testify v1.10.0
gorm.io/driver/mysql v1.5.7
gorm.io/driver/mysql v1.6.0
gorm.io/driver/postgres v1.6.0
gorm.io/driver/sqlite v1.5.7
gorm.io/driver/sqlite v1.6.0
gorm.io/driver/sqlserver v1.6.0
gorm.io/gorm v1.30.0
)
@ -27,7 +27,7 @@ require (
github.com/jinzhu/inflection v1.0.0 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/mattn/go-sqlite3 v1.14.28 // indirect
github.com/microsoft/go-mssqldb v1.8.1 // indirect
github.com/microsoft/go-mssqldb v1.8.2 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/rogpeppe/go-internal v1.12.0 // indirect
golang.org/x/crypto v0.38.0 // indirect

View File

@ -41,7 +41,7 @@ func TestManyToManyWithMultiPrimaryKeys(t *testing.T) {
t.Skip("skip sqlite, sqlserver due to it doesn't support multiple primary keys with auto increment")
}
if name := DB.Dialector.Name(); name == "postgres" {
if name := DB.Dialector.Name(); name == "postgres" || name == "mysql" {
stmt := gorm.Statement{DB: DB}
stmt.Parse(&Blog{})
stmt.Schema.LookUpField("ID").Unique = true
@ -264,7 +264,7 @@ func TestManyToManyWithCustomizedForeignKeys2(t *testing.T) {
t.Skip("skip sqlite, sqlserver due to it doesn't support multiple primary keys with auto increment")
}
if name := DB.Dialector.Name(); name == "postgres" {
if name := DB.Dialector.Name(); name == "postgres" || name == "mysql" {
t.Skip("skip postgres due to it only allow unique constraint matching given keys")
}
@ -332,7 +332,7 @@ func TestManyToManyWithCustomizedForeignKeys2(t *testing.T) {
DB.Model(&blog2).Association("LocaleTags").Find(&tags)
if !compareTags(tags, []string{"tag4"}) {
t.Fatalf("Should find 1 tags for EN Blog")
t.Fatalf("Should find 1 tags for EN Blog, but got %v", tags)
}
// Replace

View File

@ -696,6 +696,10 @@ func TestManyToManyPreloadWithMultiPrimaryKeys(t *testing.T) {
t.Skip("skip sqlite, sqlserver due to it doesn't support multiple primary keys with auto increment")
}
if name := DB.Dialector.Name(); name == "mysql" {
t.Skip("skip mysql due to it only allow unique constraint matching given keys")
}
type (
Level1 struct {
ID uint `gorm:"primary_key;"`