Gorm: How to define two Multiple-Column indexs with one same index?

Created on 8 Oct 2016  ·  1Comment  ·  Source: go-gorm/gorm

How to define two Multiple-Column indexs with one same index?

Such as:

type Message struct {
       Uid    int64 `gorm:"index:idx_uid_time"`
       Roomid int64 `gorm:"index:idx_roomid_time"`
       Time   int64 `gorm:"index:id_uid_time;index:idx_roomid_time"`
       Data   string
}

This don't work.
I read the source code. model_struct.go:parseTagSetting:547 use setting := map[string]string{}, this code setting[k] = strings.Join(v[1:], ":") ensure use only one index. So Time only use index:idx_roomid_time.
How can I do with that? Thanks.

Most helpful comment

gorm:"index:id_uid_time,idx_roomid_time"

>All comments

gorm:"index:id_uid_time,idx_roomid_time"

Was this page helpful?
0 / 5 - 0 ratings

Related issues

MikeJinhua picture MikeJinhua  ·  22Comments

aimuz picture aimuz  ·  24Comments

badoet picture badoet  ·  162Comments

feige84 picture feige84  ·  19Comments

MikeJinhua picture MikeJinhua  ·  14Comments