1
0
mirror of https://github.com/astaxie/beego.git synced 2025-07-03 17:40:18 +00:00

support reverse m2m relation

This commit is contained in:
slene
2013-11-06 21:08:12 +08:00
parent 2abda0954b
commit 9492e4131b
3 changed files with 78 additions and 6 deletions

View File

@ -119,8 +119,11 @@ func (o *orm) QueryM2M(md interface{}, name string) QueryM2Mer {
mi, ind := o.getMiInd(md)
fi := o.getFieldInfo(mi, name)
if fi.fieldType != RelManyToMany {
panic(fmt.Errorf("<Ormer.QueryM2M> name `%s` for model `%s` is not a m2m field", fi.name, mi.fullName))
switch {
case fi.fieldType == RelManyToMany:
case fi.fieldType == RelReverseMany && fi.reverseFieldInfo.mi.isThrough:
default:
panic(fmt.Errorf("<Ormer.QueryM2M> model `%s` . name `%s` is not a m2m field", fi.name, mi.fullName))
}
return newQueryM2M(md, o, mi, fi, ind)