mirror of https://github.com/VinGarcia/ksql.git
Fix bug on FillStructWith so it ignores extra columns correctly
This bug was not being detected before because depending on the order of the attributes on a map instance this test would succeed by accident. I was lucky enough to reproduce this error enough times to understand it so it was possible to fix it.pull/2/head
parent
247cdc0fd6
commit
ea7a23f32f
|
@ -81,10 +81,15 @@ func FillStructWith(record interface{}, dbRow map[string]interface{}) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
info := getCachedTagInfo(tagInfoCache, t)
|
info := getCachedTagInfo(tagInfoCache, t)
|
||||||
|
|
||||||
for colName, rawSrc := range dbRow {
|
for colName, rawSrc := range dbRow {
|
||||||
|
fieldIdx, found := info.Index[colName]
|
||||||
|
if !found {
|
||||||
|
// Ignore columns not tagged with `kissorm:""`
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
src := NewPtrConverter(rawSrc)
|
src := NewPtrConverter(rawSrc)
|
||||||
dest := v.Field(info.Index[colName])
|
dest := v.Field(fieldIdx)
|
||||||
destType := t.Field(info.Index[colName]).Type
|
destType := t.Field(info.Index[colName]).Type
|
||||||
|
|
||||||
destValue, err := src.Convert(destType)
|
destValue, err := src.Convert(destType)
|
||||||
|
|
Loading…
Reference in New Issue