klyn.data.sql.SQLServerDialect.paginate
method
public paginate(sql as String, hasOrder as Boolean, offset as Long, limit as Long) as String:
Description

Applies SQL Server pagination to a generated SELECT statement.

A limit without an offset is rendered with TOP, which works on every SQL Server compatibility level and does not require a synthetic order. Offset pagination uses the native OFFSET/FETCH form.

Parameters
ParameterDescription
sqlGenerated SELECT statement.
hasOrderWhether the statement already contains ORDER BY.
offsetNumber of rows to skip.
limitMaximum number of rows, or a negative value for no limit.
Returns

SQL Server SELECT statement with native pagination.

Example
dialect = SQLServerDialect()
assert dialect.paginate("SELECT [id] FROM [users]", false, 0l, 1l) ==
"SELECT TOP (1) [id] FROM [users]"