When using a belongs-to relation with foreignKey and references overwrite preloading does not work. (Adress2)
When not overwriting it works as expected. (Address1)
type Country1 struct {
Name string `gorm:"primaryKey"`
}
type Country2 struct {
CName string `gorm:"primaryKey"`
}
type Address1 struct {
CountryName string
Country Country1
}
type Address2 struct {
CName string
Country Country2 `gorm:"foreignKey:CName;references:CName"`
}
Explain your user case and expected results
When using a belongs-to relation with foreignKey and references overwrite preloading does not work. (
Adress2
) When not overwriting it works as expected. (Address1
)