mirror of https://github.com/go-gorm/gorm.git
Fix AssociationForeignFieldNames for many2many relations
This commit is contained in:
parent
f00b95d305
commit
6a7dda9a32
|
@ -247,7 +247,7 @@ func (scope *Scope) GetModelStruct() *ModelStruct {
|
||||||
|
|
||||||
for _, name := range associationForeignKeys {
|
for _, name := range associationForeignKeys {
|
||||||
if field, ok := toScope.FieldByName(name); ok {
|
if field, ok := toScope.FieldByName(name); ok {
|
||||||
relationship.AssociationForeignFieldNames = append(relationship.AssociationForeignFieldNames, name)
|
relationship.AssociationForeignFieldNames = append(relationship.AssociationForeignFieldNames, field.DBName)
|
||||||
joinTableDBName := ToDBName(elemType.Name()) + "_" + field.DBName
|
joinTableDBName := ToDBName(elemType.Name()) + "_" + field.DBName
|
||||||
relationship.AssociationForeignDBNames = append(relationship.AssociationForeignDBNames, joinTableDBName)
|
relationship.AssociationForeignDBNames = append(relationship.AssociationForeignDBNames, joinTableDBName)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue