Fix failure caused by nil bean
This commit is contained in:
parent
7fc1fe6524
commit
2eccd7cc30
|
@ -398,12 +398,19 @@ 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
|
||||||
ckb := reflect.ValueOf(bean).Elem().Type()
|
isHit := func() (ht bool) {
|
||||||
ht := ckb == t
|
if bean == nil {
|
||||||
if !ht && t.Kind() == reflect.Ptr {
|
ht = false
|
||||||
ht = t.Elem() == ckb
|
return
|
||||||
|
}
|
||||||
|
ckb := reflect.ValueOf(bean).Elem().Type()
|
||||||
|
ht = ckb == t
|
||||||
|
if !ht && t.Kind() == reflect.Ptr {
|
||||||
|
ht = t.Elem() == ckb
|
||||||
|
}
|
||||||
|
return
|
||||||
}
|
}
|
||||||
if bean == nil || !ht {
|
if !isHit() {
|
||||||
ides = append(ides, id)
|
ides = append(ides, id)
|
||||||
ididxes[sid] = idx
|
ididxes[sid] = idx
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue