Fix #55
- Previously each call to qm.Load would overwrite your eager loading statement. I think this was deliberate at one point but it's pretty inconsistent. If we need to overwrite we can call queries.SetLoad()
This commit is contained in:
parent
2c534361e1
commit
de8f0bc26e
2 changed files with 6 additions and 1 deletions
|
@ -26,7 +26,7 @@ func SQL(sql string, args ...interface{}) QueryMod {
|
||||||
// singular, you need to specify the singular form and vice versa.
|
// singular, you need to specify the singular form and vice versa.
|
||||||
func Load(relationships ...string) QueryMod {
|
func Load(relationships ...string) QueryMod {
|
||||||
return func(q *queries.Query) {
|
return func(q *queries.Query) {
|
||||||
queries.SetLoad(q, relationships...)
|
queries.AppendLoad(q, relationships...)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -175,6 +175,11 @@ func SetLoad(q *Query, relationships ...string) {
|
||||||
q.load = append([]string(nil), relationships...)
|
q.load = append([]string(nil), relationships...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// AppendLoad on the query.
|
||||||
|
func AppendLoad(q *Query, relationships ...string) {
|
||||||
|
q.load = append(q.load, relationships...)
|
||||||
|
}
|
||||||
|
|
||||||
// SetSelect on the query.
|
// SetSelect on the query.
|
||||||
func SetSelect(q *Query, sel []string) {
|
func SetSelect(q *Query, sel []string) {
|
||||||
q.selectCols = sel
|
q.selectCols = sel
|
||||||
|
|
Loading…
Reference in a new issue