improved & bug fixed
This commit is contained in:
parent
2a5d411c8c
commit
872633e699
12
session.go
12
session.go
|
@ -747,11 +747,6 @@ func (session *Session) cacheFind(t reflect.Type, sqlStr string, rowsSlicePtr in
|
||||||
return ErrCacheFailed
|
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() {
|
for _, filter := range session.Engine.dialect.Filters() {
|
||||||
sqlStr = filter.Do(sqlStr, session.Engine.dialect, session.Statement.RefTable)
|
sqlStr = filter.Do(sqlStr, session.Engine.dialect, session.Statement.RefTable)
|
||||||
}
|
}
|
||||||
|
@ -1143,10 +1138,9 @@ func (session *Session) Find(rowsSlicePtr interface{}, condiBean ...interface{})
|
||||||
} else {
|
} else {
|
||||||
// !oinume! Add "<col> IS NULL" to WHERE whatever condiBean is given.
|
// !oinume! Add "<col> IS NULL" to WHERE whatever condiBean is given.
|
||||||
// See https://github.com/go-xorm/xorm/issues/179
|
// See https://github.com/go-xorm/xorm/issues/179
|
||||||
for _, col := range table.Columns() {
|
if col := table.DeletedColumn(); col != nil && !session.Statement.unscoped { // tag "deleted" is enabled
|
||||||
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.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))
|
session.Engine.Quote(col.Name), session.Engine.Quote(col.Name))
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1183,7 +1183,9 @@ func (statement *Statement) genCountSql(bean interface{}) (string, []interface{}
|
||||||
|
|
||||||
func (statement *Statement) genSelectSql(columnStr string) (a string) {
|
func (statement *Statement) genSelectSql(columnStr string) (a string) {
|
||||||
if statement.GroupByStr != "" {
|
if statement.GroupByStr != "" {
|
||||||
|
if columnStr == "" {
|
||||||
columnStr = statement.Engine.Quote(strings.Replace(statement.GroupByStr, ",", statement.Engine.Quote(","), -1))
|
columnStr = statement.Engine.Quote(strings.Replace(statement.GroupByStr, ",", statement.Engine.Quote(","), -1))
|
||||||
|
}
|
||||||
statement.GroupByStr = columnStr
|
statement.GroupByStr = columnStr
|
||||||
}
|
}
|
||||||
var distinct string
|
var distinct string
|
||||||
|
|
Loading…
Reference in New Issue