Struct diesel::query_builder::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>,

§

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,

§

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>,

§

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,

§

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>,

§

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>,

§

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>

§

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>

§

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,

§

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,

§

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_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 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) -> Order<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 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§

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>

§

type QueryId = ()

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

const HAS_STATIC_QUERY_ID: bool = false

Can the SQL generated by Self be uniquely identified by its type? 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 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§

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,

§

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,

§

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,

§

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,

§

type SqlType = <T as Query>::SqlType

The SQL type of Self::Query
§

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>

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

impl<T> SingleValueDsl for T

§

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>,

§

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>,

§

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