Test multiple index tags

This commit is contained in:
Jinzhu 2020-07-01 11:47:46 +08:00
parent d02b592c6c
commit fea181e87c
1 changed files with 6 additions and 1 deletions

View File

@ -16,7 +16,7 @@ type UserIndex struct {
Name5 int64 `gorm:"index:,class:FULLTEXT,comment:hello \\, world,where:age > 10"` Name5 int64 `gorm:"index:,class:FULLTEXT,comment:hello \\, world,where:age > 10"`
Name6 int64 `gorm:"index:profile,comment:hello \\, world,where:age > 10"` Name6 int64 `gorm:"index:profile,comment:hello \\, world,where:age > 10"`
Age int64 `gorm:"index:profile,expression:ABS(age)"` Age int64 `gorm:"index:profile,expression:ABS(age)"`
OID int64 `gorm:"index:idx_id"` OID int64 `gorm:"index:idx_id;index:idx_oid,unique"`
MemberNumber string `gorm:"index:idx_id"` MemberNumber string `gorm:"index:idx_id"`
} }
@ -70,6 +70,11 @@ func TestParseIndex(t *testing.T) {
Name: "idx_id", Name: "idx_id",
Fields: []schema.IndexOption{{}, {}}, Fields: []schema.IndexOption{{}, {}},
}, },
"idx_oid": {
Name: "idx_oid",
Class: "UNIQUE",
Fields: []schema.IndexOption{{}},
},
} }
indices := user.ParseIndexes() indices := user.ParseIndexes()