Merge branch 'mssqllimit' of github.com:go-xorm/xorm into mssqllimit
This commit is contained in:
commit
2ec214fcf8
|
@ -211,6 +211,7 @@ INNER JOIN SYS.COLUMNS C ON IXS.OBJECT_ID=C.OBJECT_ID
|
|||
AND IXCS.COLUMN_ID=C.COLUMN_ID
|
||||
WHERE IXS.TYPE_DESC='NONCLUSTERED' and OBJECT_NAME(IXS.OBJECT_ID) =?
|
||||
`
|
||||
|
||||
rows, err := db.DB().Query(s, args...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
10
statement.go
10
statement.go
|
@ -996,7 +996,9 @@ func (statement *Statement) genSelectSql(columnStr string) (a string) {
|
|||
}
|
||||
|
||||
if statement.Engine.dialect.DBType() == core.MSSQL {
|
||||
top = fmt.Sprintf(" TOP %d", statement.LimitN)
|
||||
if statement.LimitN > 0 {
|
||||
top = fmt.Sprintf(" TOP %d ", statement.LimitN)
|
||||
}
|
||||
if statement.Start > 0 {
|
||||
var column string = "(id)"
|
||||
if len(statement.RefTable.PKColumns()) == 0 {
|
||||
|
@ -1019,7 +1021,11 @@ func (statement *Statement) genSelectSql(columnStr string) (a string) {
|
|||
a = fmt.Sprintf("SELECT %v%v%v%v%v", top, distinct, columnStr,
|
||||
fromStr, whereStr)
|
||||
if mssqlCondi != "" {
|
||||
a += " AND " + mssqlCondi
|
||||
if whereStr != "" {
|
||||
a += " AND " + mssqlCondi
|
||||
} else {
|
||||
a += " WHERE " + mssqlCondi
|
||||
}
|
||||
}
|
||||
|
||||
if statement.GroupByStr != "" {
|
||||
|
|
Loading…
Reference in New Issue