Use no-op scanner for excess columns
This commit is contained in:
parent
2e35257eef
commit
92c575f298
15
dbc/rows.go
15
dbc/rows.go
|
@ -192,9 +192,7 @@ func (r *rows) loadStruct(typ reflect.Type, dest interface{}) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
err = r.rows.Scan(vals...)
|
if r.err = r.rows.Scan(vals...); r.err != nil {
|
||||||
if err != nil {
|
|
||||||
r.err = err
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -224,14 +222,11 @@ func (r *rows) loadSliceOfStructs(typ reflect.Type, dest interface{}) {
|
||||||
fval := val.Field(fi)
|
fval := val.Field(fi)
|
||||||
vals[i] = reflect.New(fval.Type()).Interface()
|
vals[i] = reflect.New(fval.Type()).Interface()
|
||||||
} else {
|
} else {
|
||||||
var dummy interface{}
|
vals[i] = nopScanner{}
|
||||||
vals[i] = &dummy
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
err = r.rows.Scan(vals...)
|
if r.err = r.rows.Scan(vals...); r.err != nil {
|
||||||
if err != nil {
|
|
||||||
r.err = err
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -263,3 +258,7 @@ func newValue(typ *sql.ColumnType) interface{} {
|
||||||
panic(fmt.Errorf("Unsupported MySQL type: %s", typ.DatabaseTypeName()))
|
panic(fmt.Errorf("Unsupported MySQL type: %s", typ.DatabaseTypeName()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type nopScanner struct{}
|
||||||
|
|
||||||
|
func (s *nopScanner) Scan(interface{}) error { return nil }
|
||||||
|
|
Loading…
Reference in New Issue