MCPcopy
hub / github.com/go-gorm/gorm / TestPrimarykeyIDGaussDB

Function TestPrimarykeyIDGaussDB

tests/migrate_test.go:1100–1134  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1098}
1099
1100func TestPrimarykeyIDGaussDB(t *testing.T) {
1101 t.Skipf("This test case skipped, because of gaussdb not support uuid-ossp plugin (SQLSTATE 58P01)")
1102 if DB.Dialector.Name() != "gaussdb" {
1103 return
1104 }
1105
1106 type MissPKLanguage struct {
1107 ID string `gorm:"type:uuid;default:uuid_generate_v4()"`
1108 Name string
1109 }
1110
1111 type MissPKUser struct {
1112 ID string `gorm:"type:uuid;default:uuid_generate_v4()"`
1113 MissPKLanguages []MissPKLanguage `gorm:"many2many:miss_pk_user_languages;"`
1114 }
1115
1116 var err error
1117 err = DB.Migrator().DropTable(&MissPKUser{}, &MissPKLanguage{})
1118 if err != nil {
1119 t.Fatalf("DropTable err:%v", err)
1120 }
1121 // TODO: ERROR: could not open extension control file: No such file or directory (SQLSTATE 58P01)
1122 DB.Exec(`CREATE EXTENSION IF NOT EXISTS "uuid-ossp";`)
1123
1124 err = DB.AutoMigrate(&MissPKUser{}, &MissPKLanguage{})
1125 if err != nil {
1126 t.Fatalf("AutoMigrate err:%v", err)
1127 }
1128
1129 // patch
1130 err = DB.AutoMigrate(&MissPKUser{}, &MissPKLanguage{})
1131 if err != nil {
1132 t.Fatalf("AutoMigrate err:%v", err)
1133 }
1134}
1135
1136func TestCurrentTimestamp(t *testing.T) {
1137 if DB.Dialector.Name() != "mysql" {

Callers

nothing calls this directly

Calls 5

NameMethod · 0.65
DropTableMethod · 0.65
MigratorMethod · 0.65
ExecMethod · 0.65
AutoMigrateMethod · 0.65

Tested by

no test coverage detected