https://github.com/go-gorm/gorm/issues/5320
(t *testing.T)
| 1063 | |
| 1064 | // https://github.com/go-gorm/gorm/issues/5320 |
| 1065 | func TestPrimarykeyID(t *testing.T) { |
| 1066 | if DB.Dialector.Name() != "postgres" { |
| 1067 | return |
| 1068 | } |
| 1069 | |
| 1070 | type MissPKLanguage struct { |
| 1071 | ID string `gorm:"type:uuid;default:uuid_generate_v4()"` |
| 1072 | Name string |
| 1073 | } |
| 1074 | |
| 1075 | type MissPKUser struct { |
| 1076 | ID string `gorm:"type:uuid;default:uuid_generate_v4()"` |
| 1077 | MissPKLanguages []MissPKLanguage `gorm:"many2many:miss_pk_user_languages;"` |
| 1078 | } |
| 1079 | |
| 1080 | var err error |
| 1081 | err = DB.Migrator().DropTable(&MissPKUser{}, &MissPKLanguage{}) |
| 1082 | if err != nil { |
| 1083 | t.Fatalf("DropTable err:%v", err) |
| 1084 | } |
| 1085 | |
| 1086 | DB.Exec(`CREATE EXTENSION IF NOT EXISTS "uuid-ossp";`) |
| 1087 | |
| 1088 | err = DB.AutoMigrate(&MissPKUser{}, &MissPKLanguage{}) |
| 1089 | if err != nil { |
| 1090 | t.Fatalf("AutoMigrate err:%v", err) |
| 1091 | } |
| 1092 | |
| 1093 | // patch |
| 1094 | err = DB.AutoMigrate(&MissPKUser{}, &MissPKLanguage{}) |
| 1095 | if err != nil { |
| 1096 | t.Fatalf("AutoMigrate err:%v", err) |
| 1097 | } |
| 1098 | } |
| 1099 | |
| 1100 | func TestPrimarykeyIDGaussDB(t *testing.T) { |
| 1101 | t.Skipf("This test case skipped, because of gaussdb not support uuid-ossp plugin (SQLSTATE 58P01)") |
nothing calls this directly
no test coverage detected