bug fixed for soft deleted on order by and limit

This commit is contained in:
Lunny Xiao 2016-02-04 17:46:42 +08:00
parent c4b974fe5c
commit cb1be6129d
3 changed files with 23 additions and 3 deletions

View File

@ -1 +1 @@
xorm v0.4.5.0203 xorm v0.4.5.0204

View File

@ -3962,8 +3962,28 @@ func (session *Session) Delete(bean interface{}) (int64, error) {
condition) condition)
if len(orderSql) > 0 { if len(orderSql) > 0 {
switch session.Engine.dialect.DBType() {
case core.POSTGRES:
inSql := fmt.Sprintf("ctid IN (SELECT ctid FROM %s%s)", tableName, orderSql)
if len(condition) > 0 {
realSql += " AND " + inSql
} else {
realSql += " WHERE " + inSql
}
case core.SQLITE:
inSql := fmt.Sprintf("rowid IN (SELECT rowid FROM %s%s)", tableName, orderSql)
if len(condition) > 0 {
realSql += " AND " + inSql
} else {
realSql += " WHERE " + inSql
}
// TODO: how to handle delete limit on mssql?
case core.MSSQL:
return 0, ErrNotImplemented
default:
realSql += orderSql realSql += orderSql
} }
}
// !oinume! Insert NowTime to the head of session.Statement.Params // !oinume! Insert NowTime to the head of session.Statement.Params
session.Statement.Params = append(session.Statement.Params, "") session.Statement.Params = append(session.Statement.Params, "")

View File

@ -17,7 +17,7 @@ import (
) )
const ( const (
Version string = "0.4.5.0203" Version string = "0.4.5.0204"
) )
func regDrvsNDialects() bool { func regDrvsNDialects() bool {