2023-09-20 02:07:03 +00:00
|
|
|
// Copyright 2022 The Xorm Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
|
|
|
package statements
|
|
|
|
|
|
|
|
import (
|
|
|
|
"xorm.io/builder"
|
|
|
|
)
|
|
|
|
|
|
|
|
// isUsingLegacy returns true if xorm uses legacy LIMIT OFFSET.
|
|
|
|
// It's only available in sqlserver and oracle, if param USE_LEGACY_LIMIT_OFFSET is set to "true"
|
|
|
|
func (statement *Statement) isUsingLegacyLimitOffset() bool {
|
|
|
|
u, ok := statement.dialect.(interface{ UseLegacyLimitOffset() bool })
|
|
|
|
return ok && u.UseLegacyLimitOffset()
|
|
|
|
}
|
|
|
|
|
|
|
|
// write mssql legacy query sql
|
|
|
|
func (statement *Statement) writeMssqlLegacySelect(buf *builder.BytesWriter, columnStr string) error {
|
2023-10-25 07:11:18 +00:00
|
|
|
return statement.writeMultiple(buf,
|
|
|
|
statement.writeStrings("SELECT"),
|
|
|
|
statement.writeTop,
|
2024-04-24 13:47:05 +00:00
|
|
|
statement.writeDistinct,
|
|
|
|
statement.writeStrings(" ", columnStr),
|
2023-09-20 02:07:03 +00:00
|
|
|
statement.writeFrom,
|
|
|
|
statement.writeWhereWithMssqlPagination,
|
2023-10-25 07:11:18 +00:00
|
|
|
statement.writeGroupBy,
|
|
|
|
statement.writeHaving,
|
|
|
|
statement.writeOrderBys,
|
|
|
|
statement.writeForUpdate,
|
|
|
|
)
|
2023-09-20 02:07:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (statement *Statement) writeOracleLegacySelect(buf *builder.BytesWriter, columnStr string) error {
|
2023-10-25 07:11:18 +00:00
|
|
|
return statement.writeMultiple(buf,
|
|
|
|
statement.writeSelectColumns(columnStr),
|
2023-09-20 02:07:03 +00:00
|
|
|
statement.writeFrom,
|
2024-02-05 11:13:17 +00:00
|
|
|
statement.writeWhere,
|
2023-10-25 07:11:18 +00:00
|
|
|
statement.writeOracleLimit(columnStr),
|
|
|
|
statement.writeGroupBy,
|
|
|
|
statement.writeHaving,
|
|
|
|
statement.writeOrderBys,
|
|
|
|
statement.writeForUpdate,
|
|
|
|
)
|
2023-09-20 02:07:03 +00:00
|
|
|
}
|