- 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:
Aaron L 2016-09-30 23:24:42 -07:00
parent 2c534361e1
commit de8f0bc26e
2 changed files with 6 additions and 1 deletions

View file

@ -26,7 +26,7 @@ func SQL(sql string, args ...interface{}) QueryMod {
// singular, you need to specify the singular form and vice versa.
func Load(relationships ...string) QueryMod {
return func(q *queries.Query) {
queries.SetLoad(q, relationships...)
queries.AppendLoad(q, relationships...)
}
}

View file

@ -175,6 +175,11 @@ func SetLoad(q *Query, relationships ...string) {
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.
func SetSelect(q *Query, sel []string) {
q.selectCols = sel