Statement

Enum Statement 

Source
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

Source§

impl Statement

Source

pub fn condition(&self) -> Option<&Condition>

Source

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.

Source

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

Source

pub fn is_delete(&self) -> bool

Source

pub fn as_delete(&self) -> Option<&Delete>

Attempts to return a reference to an inner Delete.

Source

pub fn into_delete(self) -> Option<Delete>

Consumes self and attempts to return the inner Delete.

Source

pub fn unwrap_delete(self) -> Delete

Consumes self and returns the inner Delete.

§Panics

If self is not a Statement::Delete.

Source§

impl Statement

Source

pub fn eval(&self, input: impl Input) -> Result<Value>

Source

pub fn eval_const(&self) -> Result<Value>

Source§

impl Statement

Source

pub fn filter(&self) -> Option<&Filter>

Source

pub fn filter_unwrap(&self) -> &Filter

Source

pub fn filter_or_default(&self) -> &Filter

Source

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.

Source

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.

Source

pub fn filter_expr_unwrap(&self) -> &Expr

Source

pub fn filter_expr_mut(&mut self) -> Option<&mut Expr>

Source§

impl Statement

Source

pub fn is_insert(&self) -> bool

Source

pub fn as_insert(&self) -> Option<&Insert>

Attempts to return a reference to an inner Insert.

Source

pub fn into_insert(self) -> Option<Insert>

Consumes self and attempts to return the inner Insert.

Source

pub fn unwrap_insert(self) -> Insert

Consumes self and returns the inner Insert.

§Panics

If self is not a Statement::Insert.

Source§

impl Statement

Source

pub fn is_query(&self) -> bool

Source

pub fn as_query(&self) -> Option<&Query>

Attempts to return a reference to an inner Query.

Source

pub fn as_query_mut(&mut self) -> Option<&mut Query>

Returns a mutable reference to the inner Query, if this is a query statement.

Source

pub fn into_query(self) -> Query

Consumes self and returns the inner Query.

§Panics

If self is not a Statement::Query.

Source§

impl Statement

Source

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.

Source

pub fn take_returning(&mut self) -> Option<Returning>

Take the Returning clause

Source

pub fn set_returning(&mut self, returning: Returning)

Set the Returning clause

Source

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.

Source

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.

Source

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, or UPDATE statement was created without specifying a RETURNING clause (the internal Option<Returning> is None)
  • A Query statement contains a non-SELECT body (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

Source

pub fn as_select(&self) -> Option<&Select>

Source

pub fn as_select_unwrap(&self) -> &Select

Source§

impl Statement

Source

pub fn is_update(&self) -> bool

Source§

impl Statement

Source

pub fn substitute(&mut self, input: impl Input)

Source

pub fn is_const(&self) -> bool

Source

pub fn as_update(&self) -> Option<&Update>

Attempts to return a reference to an inner Update.

Source

pub fn into_update(self) -> Option<Update>

Consumes self and attempts to return the inner Update.

Source

pub fn unwrap_update(self) -> Update

Consumes self and returns the inner Update.

§Panics

If self is not a Statement::Update.

Trait Implementations§

Source§

impl Clone for Statement

Source§

fn clone(&self) -> Statement

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Statement

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl From<Delete> for Statement

Source§

fn from(src: Delete) -> Self

Converts to this type from the input type.
Source§

impl From<Insert> for Statement

Source§

fn from(src: Insert) -> Self

Converts to this type from the input type.
Source§

impl From<Query> for Statement

Source§

fn from(value: Query) -> Self

Converts to this type from the input type.
Source§

impl From<Select> for Statement

Source§

fn from(value: Select) -> Self

Converts to this type from the input type.
Source§

impl From<Statement> for ExprStmt

Source§

fn from(value: Statement) -> Self

Converts to this type from the input type.
Source§

impl From<Update> for Statement

Source§

fn from(src: Update) -> Self

Converts to this type from the input type.
Source§

impl<'a, T: Resolve> IntoExprTarget<'a, T> for &'a Statement

Source§

fn into_expr_target(self, schema: &'a T) -> ExprTarget<'a>

Source§

impl Node for Statement

Source§

fn visit<V: Visit>(&self, visit: V)

Source§

fn visit_mut<V: VisitMut>(&mut self, visit: V)

Source§

impl PartialEq for Statement

Source§

fn eq(&self, other: &Statement) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for Statement

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V