Query

Struct Query 

Source
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: ExprSet

The body of the query. Either SELECT, UNION, VALUES, or possibly other types of queries depending on database support.

§single: bool

When 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

Source

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

Source

pub fn filter_unwrap(&self) -> &Filter

Source

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.

Source

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

Source

pub fn new(body: impl Into<ExprSet>) -> Self

Source

pub fn new_single(body: impl Into<ExprSet>) -> Self

Source

pub fn new_select(source: impl Into<Source>, filter: impl Into<Filter>) -> Self

Source

pub fn builder(body: impl Into<ExprSet>) -> QueryBuilder

Source

pub fn unit() -> Self

Source

pub fn values(values: impl Into<Values>) -> Self

Source

pub fn update(self) -> Update

Source

pub fn delete(self) -> Delete

Source

pub fn add_filter(&mut self, filter: impl Into<Filter>)

Source

pub fn add_union(&mut self, other: impl Into<Self>)

Source

pub fn include(&mut self, path: impl Into<Path>)

Source§

impl Query

Source

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.

Source

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).

Source

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.

Source

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).

Source§

impl Query

Source

pub fn into_select(self) -> Select

Trait Implementations§

Source§

impl Clone for Query

Source§

fn clone(&self) -> Query

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 Query

Source§

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

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

impl From<Query> for InsertTarget

Source§

fn from(value: Query) -> 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 Query

Source§

fn from(value: Select) -> Self

Converts to this type from the input type.
Source§

impl From<Values> for Query

Source§

fn from(value: Values) -> Self

Converts to this type from the input type.
Source§

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

Source§

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

Source§

impl Node for Query

Source§

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

Source§

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

Source§

impl PartialEq for Query

Source§

fn eq(&self, other: &Query) -> 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 Query

Auto Trait Implementations§

§

impl Freeze for Query

§

impl RefUnwindSafe for Query

§

impl Send for Query

§

impl Sync for Query

§

impl Unpin for Query

§

impl UnwindSafe for Query

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