Skip to main content

with_limit_offset

Function with_limit_offset 

Source
pub fn with_limit_offset(sql: &str, limit: usize, offset: u64) -> String
Expand description

Wraps a caller-owned SELECT as a subquery with LIMIT / OFFSET appended.

Strips a single trailing ; and surrounding whitespace from sql before wrapping so the emitted statement remains syntactically valid on every supported backend. The closing parenthesis is placed on a new line so a trailing -- line comment in the caller’s SQL cannot swallow the wrap’s own tokens.