Fix AssociationForeignFieldNames for many2many relations

This commit is contained in:
Jinzhu 2015-07-31 15:25:33 +08:00
parent f00b95d305
commit 6a7dda9a32
1 changed files with 1 additions and 1 deletions

View File

@ -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)
} }