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

Merge pull request #1127 from vanthanh2305/RelatedSel-multi-string/relation

RelatedSel multi string/relation
This commit is contained in:
astaxie 2015-05-07 23:12:29 +08:00
commit c0cfb5277c

View File

@ -115,23 +115,21 @@ func (o querySet) OrderBy(exprs ...string) QuerySeter {
// set relation model to query together.
// it will query relation models and assign to parent model.
func (o querySet) RelatedSel(params ...interface{}) QuerySeter {
var related []string
if len(params) == 0 {
o.relDepth = DefaultRelsDepth
} else {
for _, p := range params {
switch val := p.(type) {
case string:
related = append(o.related, val)
case int:
o.relDepth = val
default:
panic(fmt.Errorf("<QuerySeter.RelatedSel> wrong param kind: %v", val))
}
}
}
o.related = related
return &o
if len(params) == 0 {
o.relDepth = DefaultRelsDepth
} else {
for _, p := range params {
switch val := p.(type) {
case string:
o.related = append(o.related, val)
case int:
o.relDepth = val
default:
panic(fmt.Errorf("<QuerySeter.RelatedSel> wrong param kind: %v", val))
}
}
}
return &o
}
// set condition to QuerySeter.