From 6a7dda9a32e187c044178aadb0a4510f053a73fa Mon Sep 17 00:00:00 2001 From: Jinzhu Date: Fri, 31 Jul 2015 15:25:33 +0800 Subject: [PATCH] Fix AssociationForeignFieldNames for many2many relations --- model_struct.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/model_struct.go b/model_struct.go index 468002d5..9c07db9b 100644 --- a/model_struct.go +++ b/model_struct.go @@ -247,7 +247,7 @@ func (scope *Scope) GetModelStruct() *ModelStruct { for _, name := range associationForeignKeys { 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 relationship.AssociationForeignDBNames = append(relationship.AssociationForeignDBNames, joinTableDBName) }