public paginate(sql as String, hasOrder as Boolean, offset as Long, limit as Long) as String:
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.
| Parameter | Description |
|---|---|
sql | Generated SELECT statement. |
hasOrder | Whether the statement already contains ORDER BY. |
offset | Number of rows to skip. |
limit | Maximum number of rows, or a negative value for no limit. |
SQL Server SELECT statement with native pagination.
dialect = SQLServerDialect()
assert dialect.paginate("SELECT [id] FROM [users]", false, 0l, 1l) ==
"SELECT TOP (1) [id] FROM [users]"