1
0
Fork 0

Use no-op scanner for excess columns

This commit is contained in:
Gregory Eremin 2018-07-09 00:49:32 +02:00
parent 2e35257eef
commit 92c575f298
1 changed files with 7 additions and 8 deletions

View File

@ -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 }