Fix cache bug

This commit is contained in:
Lunny Xiao 2020-03-06 16:34:44 +08:00
parent a7791fb942
commit f4358c00fd
No known key found for this signature in database
GPG Key ID: C3B7C91B632F738A
2 changed files with 2 additions and 2 deletions

View File

@ -139,7 +139,7 @@ func (session *Session) find(rowsSlicePtr interface{}, condiBean ...interface{})
return err
}
if session.canCache() {
if session.statement.ColumnMap.IsEmpty() && session.canCache() {
if cacher := session.engine.GetCacher(session.statement.TableName()); cacher != nil &&
!session.statement.IsDistinct &&
!session.statement.GetUnscoped() {

View File

@ -65,7 +65,7 @@ func (session *Session) get(bean interface{}) (bool, error) {
table := session.statement.RefTable
if session.canCache() && beanValue.Elem().Kind() == reflect.Struct {
if session.statement.ColumnMap.IsEmpty() && session.canCache() && beanValue.Elem().Kind() == reflect.Struct {
if cacher := session.engine.GetCacher(session.statement.TableName()); cacher != nil &&
!session.statement.GetUnscoped() {
has, err := session.cacheGet(bean, sqlStr, args...)