diesel::query_builder

Struct BoxedSelectStatement

Source
#[non_exhaustive]
pub struct BoxedSelectStatement<'a, ST, QS, DB, GB = ()> { pub select: Box<dyn QueryFragment<DB> + Send + 'a>, pub from: QS, pub distinct: Box<dyn QueryFragment<DB> + Send + 'a>, pub where_clause: BoxedWhereClause<'a, DB>, pub order: Option<Box<dyn QueryFragment<DB> + Send + 'a>>, pub limit_offset: BoxedLimitOffsetClause<'a, DB>, pub group_by: Box<dyn QueryFragment<DB> + Send + 'a>, pub having: Box<dyn QueryFragment<DB> + Send + 'a>, /* private fields */ }
Available on crate feature i-implement-a-third-party-backend-and-opt-into-breaking-changes only.
Expand description

This type represents a boxed select query

Using this type directly is only meaningful for custom backends that need to provide a custom QueryFragment implementation

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§select: Box<dyn QueryFragment<DB> + Send + 'a>

The select clause of the query

§from: QS

The from clause of the query

§distinct: Box<dyn QueryFragment<DB> + Send + 'a>

The distinct clause of the query

§where_clause: BoxedWhereClause<'a, DB>

The where clause of the query

§order: Option<Box<dyn QueryFragment<DB> + Send + 'a>>

The order clause of the query

§limit_offset: BoxedLimitOffsetClause<'a, DB>

The combined limit/offset clause of the query

§group_by: Box<dyn QueryFragment<DB> + Send + 'a>

The group by clause of the query

§having: Box<dyn QueryFragment<DB> + Send + 'a>

The having clause of the query

Trait Implementations§

Source§

impl<'a, ST, QS, DB, GB> AsInExpression<ST> for BoxedSelectStatement<'a, ST, QS, DB, GB>
where ST: SqlType + TypedExpressionType, Subselect<BoxedSelectStatement<'a, ST, QS, DB, GB>, ST>: Expression<SqlType = ST>,

Source§

type InExpression = Subselect<BoxedSelectStatement<'a, ST, QS, DB, GB>, ST>

Type of the expression returned by AsInExpression::as_in_expression
Source§

fn as_in_expression(self) -> Self::InExpression

Construct the diesel query dsl representation of the IN (values) clause for the given type
Source§

impl<'a, ST, QS, DB, GB> CombineDsl for BoxedSelectStatement<'a, ST, QS, DB, GB>
where Self: Query,

Source§

type Query = BoxedSelectStatement<'a, ST, QS, DB, GB>

What kind of query does this type represent?
Source§

fn union<Rhs>(self, rhs: Rhs) -> Union<Self, Rhs>
where Rhs: AsQuery<SqlType = <Self::Query as Query>::SqlType>,

Combine two queries using a SQL UNION Read more
Source§

fn union_all<Rhs>(self, rhs: Rhs) -> UnionAll<Self, Rhs>
where Rhs: AsQuery<SqlType = <Self::Query as Query>::SqlType>,

Combine two queries using a SQL UNION ALL
Source§

fn intersect<Rhs>(self, rhs: Rhs) -> Intersect<Self, Rhs>
where Rhs: AsQuery<SqlType = <Self::Query as Query>::SqlType>,

Combine two queries using a SQL INTERSECT
Source§

fn intersect_all<Rhs>(self, rhs: Rhs) -> IntersectAll<Self, Rhs>
where Rhs: AsQuery<SqlType = <Self::Query as Query>::SqlType>,

Combine two queries using a SQL INTERSECT ALL
Source§

fn except<Rhs>(self, rhs: Rhs) -> Except<Self, Rhs>
where Rhs: AsQuery<SqlType = <Self::Query as Query>::SqlType>,

Combine two queries using a SQL EXCEPT
Source§

fn except_all<Rhs>(self, rhs: Rhs) -> ExceptAll<Self, Rhs>
where Rhs: AsQuery<SqlType = <Self::Query as Query>::SqlType>,

Combine two queries using a SQL EXCEPT ALL
Source§

impl<'a, ST, QS, DB, GB> DistinctDsl for BoxedSelectStatement<'a, ST, QS, DB, GB>
where DB: Backend, DistinctClause: QueryFragment<DB>,

Source§

type Output = BoxedSelectStatement<'a, ST, QS, DB, GB>

The type returned by .distinct
Source§

fn distinct(self) -> Self::Output

See the trait documentation.
Source§

impl<'a, ST, DB, Predicate, GB> FilterDsl<Predicate> for BoxedSelectStatement<'a, ST, NoFromClause, DB, GB>
where BoxedWhereClause<'a, DB>: WhereAnd<Predicate, Output = BoxedWhereClause<'a, DB>>, Predicate: AppearsOnTable<NoFromClause> + NonAggregate, Predicate::SqlType: BoolOrNullableBool,

Source§

type Output = BoxedSelectStatement<'a, ST, NoFromClause, DB, GB>

The type returned by .filter.
Source§

fn filter(self, predicate: Predicate) -> Self::Output

See the trait documentation.
Source§

impl<'a, 'b, ST, QS, DB, T, GB> Insertable<T> for &'b BoxedSelectStatement<'a, ST, QS, DB, GB>
where T: Table, Self: Query, <T::AllColumns as ValidGrouping<()>>::IsAggregate: MixedAggregates<No, Output = No>,

Source§

type Values = InsertFromSelect<&'b BoxedSelectStatement<'a, ST, QS, DB, GB>, <T as Table>::AllColumns>

The VALUES clause to insert these records Read more
Source§

fn values(self) -> Self::Values

Construct Self::Values Read more
Source§

fn insert_into(self, table: T) -> InsertStatement<T, Self::Values>
where T: Table, Self: Sized,

Insert self into a given table. Read more
Source§

impl<'a, ST, QS, DB, T, GB> Insertable<T> for BoxedSelectStatement<'a, ST, QS, DB, GB>
where T: Table, Self: Query, <T::AllColumns as ValidGrouping<()>>::IsAggregate: MixedAggregates<No, Output = No>,

Source§

type Values = InsertFromSelect<BoxedSelectStatement<'a, ST, QS, DB, GB>, <T as Table>::AllColumns>

The VALUES clause to insert these records Read more
Source§

fn values(self) -> Self::Values

Construct Self::Values Read more
Source§

fn insert_into(self, table: T) -> InsertStatement<T, Self::Values>
where T: Table, Self: Sized,

Insert self into a given table. Read more
Source§

impl<'a, ST, QS, DB, GB> LimitDsl for BoxedSelectStatement<'a, ST, QS, DB, GB>

Source§

type Output = BoxedSelectStatement<'a, ST, QS, DB, GB>

The type returned by .limit
Source§

fn limit(self, limit: i64) -> Self::Output

See the trait documentation
Source§

impl<'a, ST, QS, DB, GB> OffsetDsl for BoxedSelectStatement<'a, ST, QS, DB, GB>

Source§

type Output = BoxedSelectStatement<'a, ST, QS, DB, GB>

The type returned by .offset.
Source§

fn offset(self, offset: i64) -> Self::Output

See the trait documentation
Source§

impl<'a, ST, DB, Predicate, GB> OrFilterDsl<Predicate> for BoxedSelectStatement<'a, ST, NoFromClause, DB, GB>
where BoxedWhereClause<'a, DB>: WhereOr<Predicate, Output = BoxedWhereClause<'a, DB>>, Predicate: AppearsOnTable<NoFromClause> + NonAggregate, Predicate::SqlType: BoolOrNullableBool,

Source§

type Output = BoxedSelectStatement<'a, ST, NoFromClause, DB, GB>

The type returned by .filter.
Source§

fn or_filter(self, predicate: Predicate) -> Self::Output

See the trait documentation.
Source§

impl<'a, ST, QS, DB, GB> Query for BoxedSelectStatement<'a, ST, QS, DB, GB>
where DB: Backend,

Source§

type SqlType = ST

The SQL type that this query represents. Read more
Source§

impl<'a, ST, QS, DB, GB> QueryDsl for BoxedSelectStatement<'a, ST, QS, DB, GB>

Source§

fn distinct(self) -> Distinct<Self>
where Self: DistinctDsl,

Adds the DISTINCT keyword to a query. Read more
Source§

fn distinct_on<Expr>(self, expr: Expr) -> DistinctOn<Self, Expr>
where Self: DistinctOnDsl<Expr>,

Available on crate feature postgres_backend only.
Adds the DISTINCT ON clause to a query. Read more
Source§

fn select<Selection>(self, selection: Selection) -> Select<Self, Selection>
where Selection: Expression, Self: SelectDsl<Selection>,

Adds a SELECT clause to the query. Read more
Source§

fn count(self) -> Select<Self, CountStar>
where Self: SelectDsl<CountStar>,

Get the count of a query. This is equivalent to .select(count_star()) Read more
Source§

fn inner_join<Rhs>(self, rhs: Rhs) -> InnerJoin<Self, Rhs>
where Self: JoinWithImplicitOnClause<Rhs, Inner>,

Join two tables using a SQL INNER JOIN. Read more
Source§

fn left_outer_join<Rhs>(self, rhs: Rhs) -> LeftJoin<Self, Rhs>
where Self: JoinWithImplicitOnClause<Rhs, LeftOuter>,

Join two tables using a SQL LEFT OUTER JOIN. Read more
Source§

fn left_join<Rhs>(self, rhs: Rhs) -> LeftJoin<Self, Rhs>
where Self: JoinWithImplicitOnClause<Rhs, LeftOuter>,

Alias for left_outer_join.
Source§

fn filter<Predicate>(self, predicate: Predicate) -> Filter<Self, Predicate>
where Self: FilterDsl<Predicate>,

Adds to the WHERE clause of a query. Read more
Source§

fn or_filter<Predicate>(self, predicate: Predicate) -> OrFilter<Self, Predicate>
where Self: OrFilterDsl<Predicate>,

Adds to the WHERE clause of a query using OR Read more
Source§

fn find<PK>(self, id: PK) -> Find<Self, PK>
where Self: FindDsl<PK>,

Attempts to find a single record from the given table by primary key. Read more
Source§

fn order<Expr>(self, expr: Expr) -> Order<Self, Expr>
where Expr: Expression, Self: OrderDsl<Expr>,

Sets the order clause of a query. Read more
Source§

fn order_by<Expr>(self, expr: Expr) -> OrderBy<Self, Expr>
where Expr: Expression, Self: OrderDsl<Expr>,

Alias for order
Source§

fn then_order_by<Order>(self, order: Order) -> ThenOrderBy<Self, Order>
where Self: ThenOrderDsl<Order>,

Appends to the ORDER BY clause of this SQL query. Read more
Source§

fn limit(self, limit: i64) -> Limit<Self>
where Self: LimitDsl,

Sets the limit clause of the query. Read more
Source§

fn offset(self, offset: i64) -> Offset<Self>
where Self: OffsetDsl,

Sets the offset clause of the query. Read more
Source§

fn group_by<GB>(self, group_by: GB) -> GroupBy<Self, GB>
where GB: Expression, Self: GroupByDsl<GB>,

Sets the group by clause of a query. Read more
Source§

fn having<Predicate>(self, predicate: Predicate) -> Having<Self, Predicate>
where Self: HavingDsl<Predicate>,

Adds to the HAVING clause of a query. Read more
Source§

fn into_boxed<'a, DB>(self) -> IntoBoxed<'a, Self, DB>
where DB: Backend, Self: BoxedDsl<'a, DB>,

Boxes the pieces of a query into a single type. Read more
Source§

fn single_value(self) -> SingleValue<Self>
where Self: SingleValueDsl,

Wraps this select statement in parenthesis, allowing it to be used as an expression. Read more
Source§

fn nullable(self) -> NullableSelect<Self>
where Self: SelectNullableDsl,

Coerce the SQL type of the select clause to it’s nullable equivalent. Read more
Source§

impl<'a, ST, QS, DB, GB> QueryFragment<DB> for BoxedSelectStatement<'a, ST, QS, DB, GB>
where DB: Backend, Self: QueryFragment<DB, DB::SelectStatementSyntax>,

Source§

fn walk_ast<'b>(&'b self, pass: AstPass<'_, 'b, DB>) -> QueryResult<()>

Walk over this QueryFragment for all passes. Read more
Source§

fn to_sql(&self, out: &mut DB::QueryBuilder, backend: &DB) -> QueryResult<()>

Available on crate feature i-implement-a-third-party-backend-and-opt-into-breaking-changes only.
Converts this QueryFragment to its SQL representation. Read more
Source§

fn collect_binds<'b>( &'b self, out: &mut DB::BindCollector<'b>, metadata_lookup: &mut DB::MetadataLookup, backend: &'b DB, ) -> QueryResult<()>

Available on crate feature i-implement-a-third-party-backend-and-opt-into-breaking-changes only.
Serializes all bind parameters in this query. Read more
Source§

fn is_safe_to_cache_prepared(&self, backend: &DB) -> QueryResult<bool>

Available on crate feature i-implement-a-third-party-backend-and-opt-into-breaking-changes only.
Is this query safe to store in the prepared statement cache? Read more
Source§

fn is_noop(&self, backend: &DB) -> QueryResult<bool>

Available on crate feature i-implement-a-third-party-backend-and-opt-into-breaking-changes only.
Does walking this AST have any effect?
Source§

impl<'a, ST, QS, DB, GB> QueryFragment<DB, AnsiSqlSelectStatement> for BoxedSelectStatement<'a, ST, QS, DB, GB>

Source§

fn walk_ast<'b>(&'b self, out: AstPass<'_, 'b, DB>) -> QueryResult<()>

Walk over this QueryFragment for all passes. Read more
Source§

fn to_sql(&self, out: &mut DB::QueryBuilder, backend: &DB) -> QueryResult<()>

Available on crate feature i-implement-a-third-party-backend-and-opt-into-breaking-changes only.
Converts this QueryFragment to its SQL representation. Read more
Source§

fn collect_binds<'b>( &'b self, out: &mut DB::BindCollector<'b>, metadata_lookup: &mut DB::MetadataLookup, backend: &'b DB, ) -> QueryResult<()>

Available on crate feature i-implement-a-third-party-backend-and-opt-into-breaking-changes only.
Serializes all bind parameters in this query. Read more
Source§

fn is_safe_to_cache_prepared(&self, backend: &DB) -> QueryResult<bool>

Available on crate feature i-implement-a-third-party-backend-and-opt-into-breaking-changes only.
Is this query safe to store in the prepared statement cache? Read more
Source§

fn is_noop(&self, backend: &DB) -> QueryResult<bool>

Available on crate feature i-implement-a-third-party-backend-and-opt-into-breaking-changes only.
Does walking this AST have any effect?
Source§

impl<'a, ST, QS, DB, GB> QueryId for BoxedSelectStatement<'a, ST, QS, DB, GB>

Source§

const HAS_STATIC_QUERY_ID: bool = false

Can the SQL generated by Self be uniquely identified by its type? Read more
Source§

type QueryId = ()

A type which uniquely represents Self in a SQL query. Read more
Source§

fn query_id() -> Option<TypeId>

Returns the type id of Self::QueryId if Self::HAS_STATIC_QUERY_ID. Returns None otherwise. Read more
Source§

impl<'a, ST, QS, DB, Conn, GB> RunQueryDsl<Conn> for BoxedSelectStatement<'a, ST, QS, DB, GB>

Source§

fn execute(self, conn: &mut Conn) -> QueryResult<usize>
where Conn: Connection, Self: ExecuteDsl<Conn>,

Executes the given command, returning the number of rows affected. Read more
Source§

fn load<'query, U>(self, conn: &mut Conn) -> QueryResult<Vec<U>>
where Self: LoadQuery<'query, Conn, U>,

Executes the given query, returning a Vec with the returned rows. Read more
Source§

fn load_iter<'conn, 'query: 'conn, U, B>( self, conn: &'conn mut Conn, ) -> QueryResult<Self::RowIter<'conn>>
where U: 'conn, Self: LoadQuery<'query, Conn, U, B> + 'conn,

Executes the given query, returning an Iterator with the returned rows. Read more
Source§

fn get_result<'query, U>(self, conn: &mut Conn) -> QueryResult<U>
where Self: LoadQuery<'query, Conn, U>,

Runs the command, and returns the affected row. Read more
Source§

fn get_results<'query, U>(self, conn: &mut Conn) -> QueryResult<Vec<U>>
where Self: LoadQuery<'query, Conn, U>,

Runs the command, returning an Vec with the affected rows. Read more
Source§

fn first<'query, U>(self, conn: &mut Conn) -> QueryResult<U>
where Self: LimitDsl, Limit<Self>: LoadQuery<'query, Conn, U>,

Attempts to load a single record. Read more
Source§

impl<'a, ST, DB, Selection, GB> SelectDsl<Selection> for BoxedSelectStatement<'a, ST, NoFromClause, DB, GB>
where DB: Backend, Selection: SelectableExpression<NoFromClause> + QueryFragment<DB> + ValidGrouping<GB> + Send + 'a,

Source§

type Output = BoxedSelectStatement<'a, <Selection as Expression>::SqlType, NoFromClause, DB, GB>

The type returned by .select
Source§

fn select(self, selection: Selection) -> Self::Output

See the trait documentation
Source§

impl<'a, ST, QS, DB, GB> SelectNullableDsl for BoxedSelectStatement<'a, ST, QS, DB, GB>
where ST: IntoNullable,

Source§

type Output = BoxedSelectStatement<'a, <ST as IntoNullable>::Nullable, QS, DB>

The return type of nullable
Source§

fn nullable(self) -> Self::Output

See the trait documentation
Source§

impl<'a, ST, QS, DB, GB> SelectQuery for BoxedSelectStatement<'a, ST, QS, DB, GB>
where DB: Backend,

Source§

type SqlType = ST

The SQL type of the SELECT clause

Auto Trait Implementations§

§

impl<'a, ST, QS, DB, GB> Freeze for BoxedSelectStatement<'a, ST, QS, DB, GB>
where QS: Freeze,

§

impl<'a, ST, QS, DB, GB = ()> !RefUnwindSafe for BoxedSelectStatement<'a, ST, QS, DB, GB>

§

impl<'a, ST, QS, DB, GB> Send for BoxedSelectStatement<'a, ST, QS, DB, GB>
where QS: Send, ST: Send, GB: Send,

§

impl<'a, ST, QS, DB, GB = ()> !Sync for BoxedSelectStatement<'a, ST, QS, DB, GB>

§

impl<'a, ST, QS, DB, GB> Unpin for BoxedSelectStatement<'a, ST, QS, DB, GB>
where QS: Unpin, ST: Unpin, GB: Unpin,

§

impl<'a, ST, QS, DB, GB = ()> !UnwindSafe for BoxedSelectStatement<'a, ST, QS, DB, GB>

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> AsQuery for T
where T: Query,

Source§

type SqlType = <T as Query>::SqlType

The SQL type of Self::Query
Source§

type Query = T

What kind of query does this type represent?
Source§

fn as_query(self) -> <T as AsQuery>::Query

Converts a type which semantically represents a SQL query into the actual query being executed. See the trait level docs for 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<Conn, DB, T> ExecuteDsl<Conn, DB> for T
where Conn: Connection<Backend = DB>, DB: Backend, T: QueryFragment<DB> + QueryId,

Source§

fn execute(query: T, conn: &mut Conn) -> Result<usize, Error>

Execute this command
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> IntoSql for T

Source§

fn into_sql<T>(self) -> AsExprOf<Self, T>

Convert self to an expression for Diesel’s query builder. Read more
Source§

fn as_sql<'a, T>(&'a self) -> AsExprOf<&'a Self, T>
where &'a Self: AsExpression<T>, T: SqlType + TypedExpressionType,

Convert &self to an expression for Diesel’s query builder. Read more
Source§

impl<T, DB> QueryFragmentForCachedStatement<DB> for T
where DB: Backend, <DB as Backend>::QueryBuilder: Default, T: QueryFragment<DB>,

Source§

fn construct_sql(&self, backend: &DB) -> Result<String, Error>

Available on crate feature i-implement-a-third-party-backend-and-opt-into-breaking-changes only.
Convert the query fragment into a SQL string for the given backend
Source§

fn is_safe_to_cache_prepared(&self, backend: &DB) -> Result<bool, Error>

Available on crate feature i-implement-a-third-party-backend-and-opt-into-breaking-changes only.
Check whether it’s safe to cache the query
Source§

impl<T> SingleValueDsl for T

Source§

type Output = Grouped<Subselect<<T as LimitDsl>::Output, <<T as SelectQuery>::SqlType as IntoNullable>::Nullable>>

The type returned by .single_value.
Source§

fn single_value(self) -> <T as SingleValueDsl>::Output

See the trait documentation.
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.
Source§

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

Source§

fn vzip(self) -> V

Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSendSync for T