diff --git a/join_table_handler.go b/join_table_handler.go index d97f6d52..14f65ffa 100644 --- a/join_table_handler.go +++ b/join_table_handler.go @@ -39,10 +39,10 @@ type JoinTableSource struct { // JoinTableHandler default join table handler type JoinTableHandler struct { - TableName string `sql:"-"` - Source JoinTableSource `sql:"-"` - Destination JoinTableSource `sql:"-"` - ArbitraryJoinConditions []string `sql:"-"` + TableName string `sql:"-"` + Source JoinTableSource `sql:"-"` + Destination JoinTableSource `sql:"-"` + ArbitraryJoinConditions []string `sql:"-"` } // SourceForeignKeys return source foreign keys @@ -67,7 +67,7 @@ func (s *JoinTableHandler) Setup(relationship *Relationship, tableName string, s AssociationDBName: dbName, }) } - + s.Destination = JoinTableSource{ModelType: destination} s.Destination.ForeignKeys = []JoinTableForeignKey{} for idx, dbName := range relationship.AssociationForeignFieldNames { diff --git a/model_struct.go b/model_struct.go index 9d49b299..823ec8b0 100644 --- a/model_struct.go +++ b/model_struct.go @@ -342,11 +342,10 @@ func (scope *Scope) GetModelStruct() *ModelStruct { // Check for arbitrary join conditions supplied in the tag - if arbitraryConditions,_ := field.TagSettingsGet("ARBITRARY_JOIN_CONDITIONS"); arbitraryConditions != "" { + if arbitraryConditions, _ := field.TagSettingsGet("ARBITRARY_JOIN_CONDITIONS"); arbitraryConditions != "" { relationship.ArbitraryJoinConditions = strings.Split(arbitraryConditions, ",") } - joinTableHandler := JoinTableHandler{} joinTableHandler.Setup(relationship, ToTableName(many2many), reflectType, elemType) relationship.JoinTableHandler = &joinTableHandler