1
0
mirror of https://github.com/astaxie/beego.git synced 2024-12-23 03:50:51 +00:00

Merge pull request #1381 from ADone/m2m_reverse_bug

fix #671
This commit is contained in:
astaxie 2015-11-04 23:20:22 +08:00
commit 25bec8bbe9
2 changed files with 9 additions and 1 deletions

View File

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

View File

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