Fix failure caused by nil bean

This commit is contained in:
shanyy 2018-04-16 15:59:01 +08:00 committed by Lunny Xiao
parent 7fc1fe6524
commit 2eccd7cc30
No known key found for this signature in database
GPG Key ID: C3B7C91B632F738A
1 changed files with 12 additions and 5 deletions

View File

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