Skip to content

Commit 6b4e052

Browse files
authored
Merge pull request #10 from lbryio/eagerloading_depth
Fix multi-depth eager loading of relationships. If a relationship is …
2 parents 256a6d4 + 3db4f30 commit 6b4e052

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

queries/eager_load.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ import (
55
"reflect"
66
"strings"
77

8-
"github.com/pkg/errors"
98
"github.com/lbryio/sqlboiler/boil"
109
"github.com/lbryio/sqlboiler/strmangle"
10+
"github.com/pkg/errors"
1111
)
1212

1313
type loadRelationshipState struct {
@@ -259,9 +259,13 @@ func collectLoaded(key string, loadingFrom reflect.Value) (reflect.Value, bindKi
259259
for {
260260
switch bkind {
261261
case kindStruct:
262-
collection = reflect.Append(collection, loadedObject)
262+
if !loadedObject.IsNil() {
263+
collection = reflect.Append(collection, loadedObject)
264+
}
263265
case kindPtrSliceStruct:
264-
collection = reflect.AppendSlice(collection, loadedObject)
266+
if !loadedObject.IsNil() {
267+
collection = reflect.AppendSlice(collection, loadedObject)
268+
}
265269
}
266270

267271
i++

0 commit comments

Comments
 (0)