pub fn apply_paging(
sql: &str,
limit: Option<usize>,
offset: Option<usize>,
backend: Backend,
) -> Result<String, SqlError>Expand description
Apply dialect-specific LIMIT / OFFSET paging to a SQL statement.
Returns the original SQL unchanged if:
- both
limitandoffsetareNone - the SQL already contains a
LIMITorOFFSETorFETCHclause - the SQL contains multiple statements (
;)
ยงDialects
| Backend | Syntax |
|---|---|
| Postgres, SQLite, MySQL | LIMIT {n} OFFSET {m} |
| MSSQL | OFFSET {m} ROWS FETCH NEXT {n} ROWS ONLY |
| Oracle (12c+) | OFFSET {m} ROWS FETCH NEXT {n} ROWS ONLY |
For MSSQL and Oracle, if no ORDER BY is present, a synthetic
ORDER BY (SELECT NULL) / ORDER BY 1 is injected and a warning
can be emitted by the caller.