Fix cacheFind

This commit is contained in:
Lunny Xiao 2021-07-21 10:53:07 +08:00
parent 54f54acfc3
commit 278e2f5b1d
No known key found for this signature in database
GPG Key ID: C3B7C91B632F738A
1 changed files with 3 additions and 2 deletions

View File

@ -475,12 +475,13 @@ func (session *Session) cacheFind(t reflect.Type, sqlStr string, rowsSlicePtr in
} else if sliceValue.Kind() == reflect.Map {
var key = ids[j]
keyType := sliceValue.Type().Key()
keyValue := reflect.New(keyType)
var ikey interface{}
if len(key) == 1 {
ikey, err = asKind(reflect.ValueOf(key[0]), keyType)
if err != nil {
if err := convertAssignV(keyValue, key[0]); err != nil {
return err
}
ikey = keyValue.Elem().Interface()
} else {
if keyType.Kind() != reflect.Slice {
return errors.New("table have multiple primary keys, key is not schemas.PK or slice")