Commit Graph

2 Commits

Author SHA1 Message Date
Lunny Xiao 37fd7d3c15 some refactors for write functions (#2342)
Reviewed-on: https://gitea.com/xorm/xorm/pulls/2342
(cherry picked from commit 0f085408af)
2023-10-28 10:05:02 +08:00
FlyingOnion c73fc585bb modify limit offset implement (#2188)
Oracle and SQLServer specific: When `LIMIT OFFSET` function is needed, use `OFFSET <offset> ROWS FETCH NEXT <limit> ROWS ONLY` to replace legacy subquery.

SQLServer specific: When `ORDER BY` is not set and `OFFSET FETCH` is set, set `statement.orderStr` to `1` (`ORDER BY 1`). See [here](https://learn.microsoft.com/zh-cn/sql/t-sql/queries/select-order-by-clause-transact-sql?view=sql-server-ver16).

MySQL specific: When limit is 0 and offset > 0, use `LIMIT 9223372036854775807` ($2^{63}-1$). See comments [here](15d171ea55/internal/statements/query.go (L314)).

Reviewed-on: https://gitea.com/xorm/xorm/pulls/2188
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: FlyingOnion <731677080@qq.com>
Co-committed-by: FlyingOnion <731677080@qq.com>
(cherry picked from commit 551de3767c)
2023-10-28 09:53:09 +08:00