pub enum Statement {
Delete(Delete),
Insert(Insert),
Query(Query),
Update(Update),
}Variants§
Delete(Delete)
Delete one or more existing records
Insert(Insert)
Create one or more instances of a model
Query(Query)
Query the database
Update(Update)
Update one or more existing records
Implementations§
Source§impl Statement
impl Statement
pub fn assignments(&self) -> Option<&Assignments>
Source§impl Statement
impl Statement
pub fn condition(&self) -> Option<&Condition>
Sourcepub fn condition_mut(&mut self) -> Option<&mut Condition>
pub fn condition_mut(&mut self) -> Option<&mut Condition>
Returns a mutable reference to the statement’s condition.
Returns None for statements that do not support conditions.
Sourcepub fn condition_mut_unwrap(&mut self) -> &mut Condition
pub fn condition_mut_unwrap(&mut self) -> &mut Condition
Returns a mutable reference to the statement’s condition.
§Panics
Panics if the statement does not support conditions.
Source§impl Statement
impl Statement
pub fn is_delete(&self) -> bool
Sourcepub fn as_delete(&self) -> Option<&Delete>
pub fn as_delete(&self) -> Option<&Delete>
Attempts to return a reference to an inner Delete.
- If
selfis aStatement::Delete, a reference to the innerDeleteis returned wrapped inSome. - Else,
Noneis returned.
Sourcepub fn into_delete(self) -> Option<Delete>
pub fn into_delete(self) -> Option<Delete>
Consumes self and attempts to return the inner Delete.
- If
selfis aStatement::Delete, innerDeleteis returned wrapped inSome. - Else,
Noneis returned.
Sourcepub fn unwrap_delete(self) -> Delete
pub fn unwrap_delete(self) -> Delete
Source§impl Statement
impl Statement
pub fn filter(&self) -> Option<&Filter>
pub fn filter_unwrap(&self) -> &Filter
pub fn filter_or_default(&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 statement’s filter.
Returns None for statements that do not support filtering, such as
INSERT.
Sourcepub fn filter_mut_unwrap(&mut self) -> &mut Filter
pub fn filter_mut_unwrap(&mut self) -> &mut Filter
Returns a mutable reference to the statement’s filter.
§Panics
Panics if the statement does not support filtering.
pub fn filter_expr_unwrap(&self) -> &Expr
pub fn filter_expr_mut(&mut self) -> Option<&mut Expr>
Source§impl Statement
impl Statement
pub fn is_insert(&self) -> bool
Sourcepub fn as_insert(&self) -> Option<&Insert>
pub fn as_insert(&self) -> Option<&Insert>
Attempts to return a reference to an inner Insert.
- If
selfis aStatement::Insert, a reference to the innerInsertis returned wrapped inSome. - Else,
Noneis returned.
Sourcepub fn into_insert(self) -> Option<Insert>
pub fn into_insert(self) -> Option<Insert>
Consumes self and attempts to return the inner Insert.
- If
selfis aStatement::Insert, innerInsertis returned wrapped inSome. - Else,
Noneis returned.
Sourcepub fn unwrap_insert(self) -> Insert
pub fn unwrap_insert(self) -> Insert
Source§impl Statement
impl Statement
pub fn is_query(&self) -> bool
Sourcepub fn as_query(&self) -> Option<&Query>
pub fn as_query(&self) -> Option<&Query>
Attempts to return a reference to an inner Query.
- If
selfis aStatement::Query, a reference to the innerQueryis returned wrapped inSome. - Else,
Noneis returned.
Sourcepub fn as_query_mut(&mut self) -> Option<&mut Query>
pub fn as_query_mut(&mut self) -> Option<&mut Query>
Returns a mutable reference to the inner Query, if this is a query statement.
- If
selfis aStatement::Query, a mutable reference to the innerQueryis returned wrapped inSome. - Else,
Noneis returned.
Sourcepub fn into_query(self) -> Query
pub fn into_query(self) -> Query
Source§impl Statement
impl Statement
Sourcepub fn returning(&self) -> Option<&Returning>
pub fn returning(&self) -> Option<&Returning>
Returns a reference to this statement’s RETURNING clause, if present.
Returns None if the statement does not have a RETURNING clause or is
a statement type that does not support RETURNING.
Sourcepub fn take_returning(&mut self) -> Option<Returning>
pub fn take_returning(&mut self) -> Option<Returning>
Take the Returning clause
Sourcepub fn set_returning(&mut self, returning: Returning)
pub fn set_returning(&mut self, returning: Returning)
Set the Returning clause
Sourcepub fn returning_unwrap(&self) -> &Returning
pub fn returning_unwrap(&self) -> &Returning
Returns a reference to this statement’s RETURNING clause.
§Panics
Panics if the statement does not have a RETURNING clause.
Sourcepub fn returning_mut(&mut self) -> Option<&mut Returning>
pub fn returning_mut(&mut self) -> Option<&mut Returning>
Returns a mutable reference to this statement’s RETURNING clause, if present.
Returns None if the statement does not have a RETURNING clause or is
a statement type that does not support RETURNING.
Sourcepub fn returning_mut_unwrap(&mut self) -> &mut Returning
pub fn returning_mut_unwrap(&mut self) -> &mut Returning
Returns a mutable reference to this statement’s RETURNING clause.
§Panics
Panics if the statement does not have a RETURNING clause. This can occur when:
- A
DELETE,INSERT, orUPDATEstatement was created without specifying aRETURNINGclause (the internalOption<Returning>isNone) - A
Querystatement contains a non-SELECTbody (e.g.,VALUES,UNION)
§Examples
let mut stmt = Statement::Insert(insert_with_returning);
let returning = stmt.returning_mut_unwrap();
// Modify the returning clause...§Notes
This method uses #[track_caller] to report the panic location at the call site
rather than inside this method, making debugging easier.
Source§impl Statement
impl Statement
pub fn substitute(&mut self, input: impl Input)
pub fn is_const(&self) -> bool
Sourcepub fn as_update(&self) -> Option<&Update>
pub fn as_update(&self) -> Option<&Update>
Attempts to return a reference to an inner Update.
- If
selfis aStatement::Update, a reference to the innerUpdateis returned wrapped inSome. - Else,
Noneis returned.
Sourcepub fn into_update(self) -> Option<Update>
pub fn into_update(self) -> Option<Update>
Consumes self and attempts to return the inner Update.
- If
selfis aStatement::Update, innerUpdateis returned wrapped inSome. - Else,
Noneis returned.