Skip to content

Commit

Permalink
Add explanatory comment
Browse files Browse the repository at this point in the history
  • Loading branch information
kszafran committed Oct 17, 2024
1 parent a58a604 commit e449916
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions sqlx.go
Original file line number Diff line number Diff line change
Expand Up @@ -1035,6 +1035,9 @@ func fieldsByTraversal(v reflect.Value, traversals [][]int, values []interface{}
} else if len(traversal) == 1 {
values[i] = reflectx.FieldByIndexes(v, traversal).Addr().Interface()
} else {
// reflectx.FieldByIndexes initializes pointer fields, including pointers to nested structs.
// Use optDest to delay it until the first non-NULL value is scanned into a field of a nested struct.
// That way we can support LEFT JOINs with optional nested structs.
traversal := traversal
values[i] = optDest(func() interface{} {
return reflectx.FieldByIndexes(v, traversal).Addr().Interface()
Expand Down

0 comments on commit e449916

Please sign in to comment.