Skip to content

Commit

Permalink
Fix multi-depth eager loading of relationships. If a relationship is …
Browse files Browse the repository at this point in the history
…nil, do not add it to the collection for checking the next depth level.
  • Loading branch information
tiger5226 committed Aug 20, 2020
1 parent 256a6d4 commit 3db4f30
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 3db4f30

Please sign in to comment.