go version)?go version go1.8.3 linux/amd64
mysql Ver 15.1 Distrib 5.5.52-MariaDB, for Linux (x86_64) using readline 5.1
My Model:
type User struct {
ID string `gorm:"primary_key"`
BelongsToUser string
BelongsTo *User `gorm:"ForeignKey:BelongsToUser"`
}
expecting for a belongs-to referencing but behaving as has-one referencing
Change to?
type User struct {
ID string `gorm:"primary_key"`
BelongsToID string
BelongsTo *User
}
What if you have struct property names you can not change?
type User struct {
UUID string `gorm:"primary_key"`
BelongsToUUID string
BelongsTo *User
}
I can not easily change the struct property name of BelongsToUUID to BelongsToID. Can I specify in some kind of tag?
Same issue here.
same here ...
Most helpful comment
Same issue here.