Backreferences ignore custom join tables
https://github.com/zhaogongchengsi/gorm-bug-recurrence
type User struct {
Id uint `gorm:"primaryKey"`
Name string
NickName string
Avatar string
Addresses []Address `gorm:"many2many:user_address;"`
}
type Address struct {
ID uint
Name string
// 当开启这个反向引用之后会忽略自定义的连接表 PersonAddress 从而使用 user_address 创建一个自定义的中间表 (你是故意忽略的? 还是不小心忽略的?)
// When this backreference is enabled, the custom join table PersonAddress is ignored to create a custom intermediate table using user_address
//Users []User `gorm:"many2many:user_address;"`
}
type PersonAddress struct {
UserID int `gorm:"primaryKey"`
AddressID int `gorm:"primaryKey"`
CreatedAt time.Time
DeletedAt gorm.DeletedAt
}
func (PersonAddress) TableName() string {
return "user_address"
}
Comment From: github-actions[bot]
The issue has been automatically marked as stale as it missing playground pull request link, which is important to help others understand your issue effectively and make sure the issue hasn't been fixed on latest master, checkout https://github.com/go-gorm/playground for details. it will be closed in 30 days if no further activity occurs. if you are asking question, please use the Question template, most likely your question already answered https://github.com/go-gorm/gorm/issues or described in the document https://gorm.io ✨ Search Before Asking ✨