Skip to content

Commit 54352ec

Browse files
committed
Add explanatory comment
1 parent 38bd094 commit 54352ec

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

sqlx.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1032,6 +1032,9 @@ func fieldsByTraversal(v reflect.Value, traversals [][]int, values []interface{}
10321032
} else if len(traversal) == 1 {
10331033
values[i] = reflectx.FieldByIndexes(v, traversal).Addr().Interface()
10341034
} else {
1035+
// reflectx.FieldByIndexes initializes pointer fields, including pointers to nested structs.
1036+
// Use optDest to delay it until the first non-NULL value is scanned into a field of a nested struct.
1037+
// That way we can support LEFT JOINs with optional nested structs.
10351038
traversal := traversal
10361039
values[i] = optDest(func() interface{} {
10371040
return reflectx.FieldByIndexes(v, traversal).Addr().Interface()

0 commit comments

Comments
 (0)