Judge both type of struct and pointer in case of out-of-range

This commit is contained in:
shanyy 2018-04-16 15:08:28 +08:00
parent 9e1c0ee31d
commit e4f17e61d5
1 changed files with 5 additions and 4 deletions

View File

@ -392,11 +392,12 @@ func (session *Session) cacheFind(t reflect.Type, sqlStr string, rowsSlicePtr in
bean := cacher.GetBean(tableName, sid) bean := cacher.GetBean(tableName, sid)
// fix issue #894 // fix issue #894
ckt := t ckb := reflect.ValueOf(bean).Elem().Type()
if ckt.Kind() == reflect.Ptr { ht := ckb == t
ckt = t.Elem() if !ht && t.Kind() == reflect.Ptr {
ht = t.Elem() == ckb
} }
if bean == nil || reflect.ValueOf(bean).Elem().Type() != ckt { if bean == nil || !ht {
ides = append(ides, id) ides = append(ides, id)
ididxes[sid] = idx ididxes[sid] = idx
} else { } else {