pub struct Query {
pub with: Option<With>,
pub body: ExprSet,
pub single: bool,
pub order_by: Option<OrderBy>,
pub limit: Option<Limit>,
pub locks: Vec<Lock>,
}Fields§
§with: Option<With>Any CTEs
body: ExprSetThe body of the query. Either SELECT, UNION, VALUES, or possibly
other types of queries depending on database support.
single: boolWhen true, the Query returns a single record vs. a list. Note, that
this is different from LIMIT 1 as there should only ever be 1 possible
result. Also, the return type becomes Record instead of List.
order_by: Option<OrderBy>ORDER BY
limit: Option<Limit>LIMIT and OFFSET (count or keyset)
locks: Vec<Lock>FOR { UPDATE | SHARE }
Implementations§
Source§impl Query
impl Query
pub fn filter(&self) -> Option<&Filter>
pub fn filter_unwrap(&self) -> &Filter
Sourcepub fn filter_mut(&mut self) -> Option<&mut Filter>
pub fn filter_mut(&mut self) -> Option<&mut Filter>
Returns a mutable reference to the query’s filter.
Returns None for queries that are not SELECT statements, such as
UNION or VALUES.
Sourcepub fn filter_mut_unwrap(&mut self) -> &mut Filter
pub fn filter_mut_unwrap(&mut self) -> &mut Filter
Returns a mutable reference to the query’s filter.
§Panics
Panics if the query body is not a SELECT statement.
Source§impl Query
impl Query
pub fn new(body: impl Into<ExprSet>) -> Self
pub fn new_single(body: impl Into<ExprSet>) -> Self
pub fn new_select(source: impl Into<Source>, filter: impl Into<Filter>) -> Self
pub fn builder(body: impl Into<ExprSet>) -> QueryBuilder
pub fn unit() -> Self
pub fn values(values: impl Into<Values>) -> Self
pub fn update(self) -> Update
pub fn delete(self) -> Delete
pub fn add_filter(&mut self, filter: impl Into<Filter>)
pub fn add_union(&mut self, other: impl Into<Self>)
pub fn include(&mut self, path: impl Into<Path>)
Source§impl Query
impl Query
Sourcepub fn returning(&self) -> Option<&Returning>
pub fn returning(&self) -> Option<&Returning>
Returns a reference to this query’s RETURNING clause, if present.
Returns Some only for SELECT queries. Other query types (VALUES,
UNION, etc.) do not have a RETURNING clause.
Sourcepub fn returning_unwrap(&self) -> &Returning
pub fn returning_unwrap(&self) -> &Returning
Returns a reference to this query’s RETURNING clause.
§Panics
Panics if the query does not have a RETURNING clause (i.e., the body
is not a SELECT).
Sourcepub fn returning_mut(&mut self) -> Option<&mut Returning>
pub fn returning_mut(&mut self) -> Option<&mut Returning>
Returns a mutable reference to this query’s RETURNING clause, if present.
Returns Some only for SELECT queries. Other query types (VALUES,
UNION, etc.) do not have a RETURNING clause.
Sourcepub fn returning_mut_unwrap(&mut self) -> &mut Returning
pub fn returning_mut_unwrap(&mut self) -> &mut Returning
Returns a mutable reference to this query’s RETURNING clause.
§Panics
Panics if the query does not have a RETURNING clause (i.e., the body
is not a SELECT).