diff --git a/session.go b/session.go index 71449bbd..8c3de345 100644 --- a/session.go +++ b/session.go @@ -747,11 +747,6 @@ func (session *Session) cacheFind(t reflect.Type, sqlStr string, rowsSlicePtr in return ErrCacheFailed } - // TODO: remove this after multi pk supported - /*if len(session.Statement.RefTable.PrimaryKeys) != 1 { - return ErrCacheFailed - }*/ - for _, filter := range session.Engine.dialect.Filters() { sqlStr = filter.Do(sqlStr, session.Engine.dialect, session.Statement.RefTable) } @@ -1143,10 +1138,9 @@ func (session *Session) Find(rowsSlicePtr interface{}, condiBean ...interface{}) } else { // !oinume! Add " 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 or %v = '0001-01-01 00:00:00') ", session.Engine.Quote(col.Name), session.Engine.Quote(col.Name)) - } + if col := table.DeletedColumn(); col != nil && !session.Statement.unscoped { // tag "deleted" is enabled + session.Statement.ConditionStr = fmt.Sprintf("(%v IS NULL or %v = '0001-01-01 00:00:00') ", + session.Engine.Quote(col.Name), session.Engine.Quote(col.Name)) } } diff --git a/statement.go b/statement.go index 14a8105c..22b4f2ed 100644 --- a/statement.go +++ b/statement.go @@ -1183,7 +1183,9 @@ func (statement *Statement) genCountSql(bean interface{}) (string, []interface{} func (statement *Statement) genSelectSql(columnStr string) (a string) { if statement.GroupByStr != "" { - columnStr = statement.Engine.Quote(strings.Replace(statement.GroupByStr, ",", statement.Engine.Quote(","), -1)) + if columnStr == "" { + columnStr = statement.Engine.Quote(strings.Replace(statement.GroupByStr, ",", statement.Engine.Quote(","), -1)) + } statement.GroupByStr = columnStr } var distinct string