test: invalid cache plan with prepare stmt

This commit is contained in:
a631807682 2022-10-18 08:35:48 +08:00
parent 2a788fb20c
commit af8a53af32
No known key found for this signature in database
GPG Key ID: 137D1D75522168AB

View File

@ -850,7 +850,7 @@ func findColumnType(dest interface{}, columnName string) (
return return
} }
func TestInvalidCachedPlan(t *testing.T) { func TestInvalidCachedPlanSimpleProtocol(t *testing.T) {
if DB.Dialector.Name() != "postgres" { if DB.Dialector.Name() != "postgres" {
return return
} }
@ -885,6 +885,41 @@ func TestInvalidCachedPlan(t *testing.T) {
} }
} }
func TestInvalidCachedPlanPrepareStmt(t *testing.T) {
if DB.Dialector.Name() != "postgres" {
return
}
db, err := gorm.Open(postgres.Open(postgresDSN), &gorm.Config{PrepareStmt: true})
if err != nil {
t.Errorf("Open err:%v", err)
}
type Object1 struct{}
type Object2 struct {
Field1 string
}
type Object3 struct {
Field2 string
}
db.Migrator().DropTable("objects")
err = db.Table("objects").AutoMigrate(&Object1{})
if err != nil {
t.Errorf("AutoMigrate err:%v", err)
}
err = db.Table("objects").AutoMigrate(&Object2{})
if err != nil {
t.Errorf("AutoMigrate err:%v", err)
}
err = db.Table("objects").AutoMigrate(&Object3{})
if err != nil {
t.Errorf("AutoMigrate err:%v", err)
}
}
func TestDifferentTypeWithoutDeclaredLength(t *testing.T) { func TestDifferentTypeWithoutDeclaredLength(t *testing.T) {
type DiffType struct { type DiffType struct {
ID uint ID uint