Skip to main content

toasty_core/stmt/
limit.rs

1use super::{Expr, Offset};
2
3/// A `LIMIT` clause with an optional offset.
4///
5/// Restricts the number of rows returned by a query. The limit is an
6/// expression (typically a constant integer). An optional [`Offset`] specifies
7/// where to start (either count-based or keyset-based).
8///
9/// # Examples
10///
11/// ```ignore
12/// use toasty_core::stmt::{Limit, Expr, Value};
13///
14/// let limit = Limit {
15///     limit: Expr::from(Value::from(10_i64)),
16///     offset: None,
17/// };
18/// ```
19#[derive(Debug, Clone, PartialEq)]
20pub struct Limit {
21    /// The maximum number of rows to return.
22    pub limit: Expr,
23
24    /// Optional offset (where to start).
25    pub offset: Option<Offset>,
26}