diff --git a/orm/models_boot.go b/orm/models_boot.go index 808b7822..3690557b 100644 --- a/orm/models_boot.go +++ b/orm/models_boot.go @@ -266,7 +266,10 @@ func bootStrap() { if found == false { mForC: for _, ffi := range fi.relModelInfo.fields.fieldsByType[RelManyToMany] { - if ffi.relModelInfo == mi { + conditions := fi.relThrough != "" && fi.relThrough == ffi.relThrough || + fi.relTable != "" && fi.relTable == ffi.relTable || + fi.relThrough == "" && fi.relTable == "" + if ffi.relModelInfo == mi && conditions { found = true fi.reverseField = ffi.reverseFieldInfoTwo.name diff --git a/orm/models_info_f.go b/orm/models_info_f.go index 66dcc23a..14e1f2c6 100644 --- a/orm/models_info_f.go +++ b/orm/models_info_f.go @@ -223,6 +223,11 @@ checkType: break checkType case "many": fieldType = RelReverseMany + if tv := tags["rel_table"]; tv != "" { + fi.relTable = tv + } else if tv := tags["rel_through"]; tv != "" { + fi.relThrough = tv + } break checkType default: err = fmt.Errorf("error")