Merge branch 'oinume-bugfix-deleted-find'
This commit is contained in:
commit
9787c02273
16
session.go
16
session.go
|
@ -1019,7 +1019,9 @@ func (session *Session) Get(bean interface{}) (bool, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if session.Statement.JoinStr == "" {
|
if session.Statement.JoinStr == "" {
|
||||||
if cacher := session.Engine.getCacher2(session.Statement.RefTable); cacher != nil && session.Statement.UseCache {
|
if cacher := session.Engine.getCacher2(session.Statement.RefTable); cacher != nil &&
|
||||||
|
session.Statement.UseCache &&
|
||||||
|
!session.Statement.unscoped {
|
||||||
has, err := session.cacheGet(bean, sqlStr, args...)
|
has, err := session.cacheGet(bean, sqlStr, args...)
|
||||||
if err != ErrCacheFailed {
|
if err != ErrCacheFailed {
|
||||||
return has, err
|
return has, err
|
||||||
|
@ -1138,6 +1140,14 @@ func (session *Session) Find(rowsSlicePtr interface{}, condiBean ...interface{})
|
||||||
session.Statement.unscoped, session.Statement.mustColumnMap)
|
session.Statement.unscoped, session.Statement.mustColumnMap)
|
||||||
session.Statement.ConditionStr = strings.Join(colNames, " AND ")
|
session.Statement.ConditionStr = strings.Join(colNames, " AND ")
|
||||||
session.Statement.BeanArgs = args
|
session.Statement.BeanArgs = args
|
||||||
|
} else {
|
||||||
|
// !oinume! Add "<col> IS NULL" to WHERE whatever condiBean is given.
|
||||||
|
// See https://github.com/go-xorm/xorm/issues/179
|
||||||
|
for _, col := range table.Columns() {
|
||||||
|
if col.IsDeleted && !session.Statement.unscoped { // tag "deleted" is enabled
|
||||||
|
session.Statement.ConditionStr = fmt.Sprintf("%v IS NULL", session.Engine.Quote(col.Name))
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var sqlStr string
|
var sqlStr string
|
||||||
|
@ -1171,8 +1181,8 @@ func (session *Session) Find(rowsSlicePtr interface{}, condiBean ...interface{})
|
||||||
if session.Statement.JoinStr == "" {
|
if session.Statement.JoinStr == "" {
|
||||||
if cacher := session.Engine.getCacher2(table); cacher != nil &&
|
if cacher := session.Engine.getCacher2(table); cacher != nil &&
|
||||||
session.Statement.UseCache &&
|
session.Statement.UseCache &&
|
||||||
!session.Statement.IsDistinct {
|
!session.Statement.IsDistinct &&
|
||||||
|
!session.Statement.unscoped {
|
||||||
err = session.cacheFind(sliceElementType, sqlStr, rowsSlicePtr, args...)
|
err = session.cacheFind(sliceElementType, sqlStr, rowsSlicePtr, args...)
|
||||||
if err != ErrCacheFailed {
|
if err != ErrCacheFailed {
|
||||||
return err
|
return err
|
||||||
|
|
Loading…
Reference in New Issue