Skip to content

Commit

Permalink
Merge pull request #10 from lbryio/eagerloading_depth
Browse files Browse the repository at this point in the history
Fix multi-depth eager loading of relationships. If a relationship is …
  • Loading branch information
tiger5226 authored Sep 2, 2020
2 parents 256a6d4 + 3db4f30 commit 6b4e052
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions queries/eager_load.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import (
"reflect"
"strings"

"github.com/pkg/errors"
"github.com/lbryio/sqlboiler/boil"
"github.com/lbryio/sqlboiler/strmangle"
"github.com/pkg/errors"
)

type loadRelationshipState struct {
Expand Down Expand Up @@ -259,9 +259,13 @@ func collectLoaded(key string, loadingFrom reflect.Value) (reflect.Value, bindKi
for {
switch bkind {
case kindStruct:
collection = reflect.Append(collection, loadedObject)
if !loadedObject.IsNil() {
collection = reflect.Append(collection, loadedObject)
}
case kindPtrSliceStruct:
collection = reflect.AppendSlice(collection, loadedObject)
if !loadedObject.IsNil() {
collection = reflect.AppendSlice(collection, loadedObject)
}
}

i++
Expand Down

0 comments on commit 6b4e052

Please sign in to comment.