2
0

Fix RowToStructByPos on structs with multiple anonymous sub-structs

Fixes #1343
This commit is contained in:
Baptiste Fontaine
2022-10-18 17:20:47 +00:00
committed by Jack Christensen
parent ba100785cc
commit 3e825ec898
2 changed files with 30 additions and 2 deletions
+2 -2
View File
@@ -533,9 +533,9 @@ func (rs *positionalStructRowScanner) appendScanTargets(dstElemValue reflect.Val
for i := 0; i < dstElemType.NumField(); i++ {
sf := dstElemType.Field(i)
if sf.PkgPath == "" {
// Handle anoymous struct embedding, but do not try to handle embedded pointers.
// Handle anonymous struct embedding, but do not try to handle embedded pointers.
if sf.Anonymous && sf.Type.Kind() == reflect.Struct {
scanTargets = append(scanTargets, rs.appendScanTargets(dstElemValue.Field(i), scanTargets)...)
scanTargets = rs.appendScanTargets(dstElemValue.Field(i), scanTargets)
} else {
scanTargets = append(scanTargets, dstElemValue.Field(i).Addr().Interface())
}