#[non_exhaustive]pub struct Alias<S> {
pub source: S,
}
Expand description
Represents an alias within diesel’s query builder
See alias!
for more details.
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.source: S
The inner alias definition
Implementations§
Source§impl<S: AliasSource> Alias<S>
impl<S: AliasSource> Alias<S>
Sourcepub fn field<F>(&self, field: F) -> AliasedField<S, F>
pub fn field<F>(&self, field: F) -> AliasedField<S, F>
Maps a single field of the source table in this alias
Sourcepub fn fields<Fields>(&self, fields: Fields) -> AliasedFields<S, Fields>where
Fields: FieldAliasMapper<S>,
pub fn fields<Fields>(&self, fields: Fields) -> AliasedFields<S, Fields>where
Fields: FieldAliasMapper<S>,
Maps multiple fields of the source table in this alias (takes in tuples and some expressions)
Trait Implementations§
Source§impl<S, QS> AppearsInFromClause<QS> for Alias<S>where
S: AliasSource,
S::Target: AliasAppearsInFromClause<S, QS>,
impl<S, QS> AppearsInFromClause<QS> for Alias<S>where
S: AliasSource,
S::Target: AliasAppearsInFromClause<S, QS>,
Source§type Count = <<S as AliasSource>::Target as AliasAppearsInFromClause<S, QS>>::Count
type Count = <<S as AliasSource>::Target as AliasAppearsInFromClause<S, QS>>::Count
How many times does
Self
appear in QS
?Source§impl<S> AsQuery for Alias<S>where
S: AliasSource,
S::Target: AsQuery,
Self: QuerySource,
<Self as QuerySource>::DefaultSelection: ValidGrouping<()>,
impl<S> AsQuery for Alias<S>where
S: AliasSource,
S::Target: AsQuery,
Self: QuerySource,
<Self as QuerySource>::DefaultSelection: ValidGrouping<()>,
Source§type SqlType = <<Alias<S> as QuerySource>::DefaultSelection as Expression>::SqlType
type SqlType = <<Alias<S> as QuerySource>::DefaultSelection as Expression>::SqlType
The SQL type of
Self::Query
Source§type Query = SelectStatement<FromClause<Alias<S>>>
type Query = SelectStatement<FromClause<Alias<S>>>
What kind of query does this type represent?
Source§impl<'a, S, DB> BoxedDsl<'a, DB> for Alias<S>where
Alias<S>: QuerySource + AsQuery<Query = SelectStatement<FromClause<Alias<S>>>>,
SelectStatement<FromClause<Alias<S>>>: BoxedDsl<'a, DB>,
<Alias<S> as QuerySource>::DefaultSelection: Expression<SqlType = <Alias<S> as AsQuery>::SqlType> + ValidGrouping<()>,
<Alias<S> as AsQuery>::SqlType: TypedExpressionType,
impl<'a, S, DB> BoxedDsl<'a, DB> for Alias<S>where
Alias<S>: QuerySource + AsQuery<Query = SelectStatement<FromClause<Alias<S>>>>,
SelectStatement<FromClause<Alias<S>>>: BoxedDsl<'a, DB>,
<Alias<S> as QuerySource>::DefaultSelection: Expression<SqlType = <Alias<S> as AsQuery>::SqlType> + ValidGrouping<()>,
<Alias<S> as AsQuery>::SqlType: TypedExpressionType,
Source§type Output = <SelectStatement<FromClause<Alias<S>>> as BoxedDsl<'a, DB>>::Output
type Output = <SelectStatement<FromClause<Alias<S>>> as BoxedDsl<'a, DB>>::Output
The return type of
internal_into_boxed
Source§fn internal_into_boxed(self) -> Self::Output
fn internal_into_boxed(self) -> Self::Output
See the trait documentation.
Source§impl<S> CombineDsl for Alias<S>
impl<S> CombineDsl for Alias<S>
Source§fn union<Rhs>(self, rhs: Rhs) -> Union<Self, Rhs>
fn union<Rhs>(self, rhs: Rhs) -> Union<Self, Rhs>
Combine two queries using a SQL
UNION
Read moreSource§fn union_all<Rhs>(self, rhs: Rhs) -> UnionAll<Self, Rhs>
fn union_all<Rhs>(self, rhs: Rhs) -> UnionAll<Self, Rhs>
Combine two queries using a SQL
UNION ALL
Source§fn intersect<Rhs>(self, rhs: Rhs) -> Intersect<Self, Rhs>
fn intersect<Rhs>(self, rhs: Rhs) -> Intersect<Self, Rhs>
Combine two queries using a SQL
INTERSECT
Source§fn intersect_all<Rhs>(self, rhs: Rhs) -> IntersectAll<Self, Rhs>
fn intersect_all<Rhs>(self, rhs: Rhs) -> IntersectAll<Self, Rhs>
Combine two queries using a SQL
INTERSECT ALL
Source§impl<S, Selection> DistinctOnDsl<Selection> for Alias<S>where
S: AliasSource,
Selection: SelectableExpression<Self>,
Self: QuerySource + AsQuery<Query = SelectStatement<FromClause<Self>>>,
SelectStatement<FromClause<Self>>: DistinctOnDsl<Selection>,
<Self as QuerySource>::DefaultSelection: Expression<SqlType = <Self as AsQuery>::SqlType> + ValidGrouping<()>,
<Self as AsQuery>::SqlType: TypedExpressionType,
Available on crate feature postgres_backend
only.
impl<S, Selection> DistinctOnDsl<Selection> for Alias<S>where
S: AliasSource,
Selection: SelectableExpression<Self>,
Self: QuerySource + AsQuery<Query = SelectStatement<FromClause<Self>>>,
SelectStatement<FromClause<Self>>: DistinctOnDsl<Selection>,
<Self as QuerySource>::DefaultSelection: Expression<SqlType = <Self as AsQuery>::SqlType> + ValidGrouping<()>,
<Self as AsQuery>::SqlType: TypedExpressionType,
Available on crate feature
postgres_backend
only.Source§type Output = <SelectStatement<FromClause<Alias<S>>> as DistinctOnDsl<Selection>>::Output
type Output = <SelectStatement<FromClause<Alias<S>>> as DistinctOnDsl<Selection>>::Output
The type returned by
.distinct_on
Source§fn distinct_on(self, selection: Selection) -> DistinctOn<Self, Selection>
fn distinct_on(self, selection: Selection) -> DistinctOn<Self, Selection>
See the trait documentation
Source§impl<S, PK> FindDsl<PK> for Alias<S>where
S: AliasSource,
S::Target: Table,
<S::Target as Table>::PrimaryKey: FieldAliasMapper<S>,
<<S::Target as Table>::PrimaryKey as FieldAliasMapper<S>>::Out: EqAll<PK>,
Self: FilterDsl<<<<S::Target as Table>::PrimaryKey as FieldAliasMapper<S>>::Out as EqAll<PK>>::Output>,
impl<S, PK> FindDsl<PK> for Alias<S>where
S: AliasSource,
S::Target: Table,
<S::Target as Table>::PrimaryKey: FieldAliasMapper<S>,
<<S::Target as Table>::PrimaryKey as FieldAliasMapper<S>>::Out: EqAll<PK>,
Self: FilterDsl<<<<S::Target as Table>::PrimaryKey as FieldAliasMapper<S>>::Out as EqAll<PK>>::Output>,
Source§impl<S, Expr> GroupByDsl<Expr> for Alias<S>where
Expr: Expression,
Self: QuerySource + AsQuery<Query = SelectStatement<FromClause<Self>>>,
<Self as QuerySource>::DefaultSelection: Expression<SqlType = <Self as AsQuery>::SqlType> + ValidGrouping<()>,
<Self as AsQuery>::SqlType: TypedExpressionType,
<Self as AsQuery>::Query: GroupByDsl<Expr>,
impl<S, Expr> GroupByDsl<Expr> for Alias<S>where
Expr: Expression,
Self: QuerySource + AsQuery<Query = SelectStatement<FromClause<Self>>>,
<Self as QuerySource>::DefaultSelection: Expression<SqlType = <Self as AsQuery>::SqlType> + ValidGrouping<()>,
<Self as AsQuery>::SqlType: TypedExpressionType,
<Self as AsQuery>::Query: GroupByDsl<Expr>,
Source§type Output = <SelectStatement<FromClause<Alias<S>>> as GroupByDsl<Expr>>::Output
type Output = <SelectStatement<FromClause<Alias<S>>> as GroupByDsl<Expr>>::Output
The type returned by
.group_by
Source§impl<S, Lock> LockingDsl<Lock> for Alias<S>where
Self: QuerySource + AsQuery<Query = SelectStatement<FromClause<Self>>>,
<Self as QuerySource>::DefaultSelection: Expression<SqlType = <Self as AsQuery>::SqlType> + ValidGrouping<()>,
<Self as AsQuery>::SqlType: TypedExpressionType,
impl<S, Lock> LockingDsl<Lock> for Alias<S>where
Self: QuerySource + AsQuery<Query = SelectStatement<FromClause<Self>>>,
<Self as QuerySource>::DefaultSelection: Expression<SqlType = <Self as AsQuery>::SqlType> + ValidGrouping<()>,
<Self as AsQuery>::SqlType: TypedExpressionType,
Source§type Output = <SelectStatement<FromClause<Alias<S>>> as LockingDsl<Lock>>::Output
type Output = <SelectStatement<FromClause<Alias<S>>> as LockingDsl<Lock>>::Output
The type returned by
set_lock
. See dsl::ForUpdate
and friends for
convenient access to this type.Source§impl<S, Predicate> OrFilterDsl<Predicate> for Alias<S>
impl<S, Predicate> OrFilterDsl<Predicate> for Alias<S>
Source§impl<S: AliasSource> QueryDsl for Alias<S>
impl<S: AliasSource> QueryDsl for Alias<S>
Source§fn distinct_on<Expr>(self, expr: Expr) -> DistinctOn<Self, Expr>where
Self: DistinctOnDsl<Expr>,
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 moreSource§fn select<Selection>(self, selection: Selection) -> Select<Self, Selection>where
Selection: Expression,
Self: SelectDsl<Selection>,
fn select<Selection>(self, selection: Selection) -> Select<Self, Selection>where
Selection: Expression,
Self: SelectDsl<Selection>,
Adds a
SELECT
clause to the query. Read moreSource§fn count(self) -> Select<Self, CountStar>
fn count(self) -> Select<Self, CountStar>
Get the count of a query. This is equivalent to
.select(count_star())
Read moreSource§fn inner_join<Rhs>(self, rhs: Rhs) -> InnerJoin<Self, Rhs>where
Self: JoinWithImplicitOnClause<Rhs, Inner>,
fn inner_join<Rhs>(self, rhs: Rhs) -> InnerJoin<Self, Rhs>where
Self: JoinWithImplicitOnClause<Rhs, Inner>,
Join two tables using a SQL
INNER JOIN
. Read moreSource§fn left_outer_join<Rhs>(self, rhs: Rhs) -> LeftJoin<Self, Rhs>where
Self: JoinWithImplicitOnClause<Rhs, LeftOuter>,
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 moreSource§fn left_join<Rhs>(self, rhs: Rhs) -> LeftJoin<Self, Rhs>where
Self: JoinWithImplicitOnClause<Rhs, LeftOuter>,
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>,
fn filter<Predicate>(self, predicate: Predicate) -> Filter<Self, Predicate>where
Self: FilterDsl<Predicate>,
Adds to the
WHERE
clause of a query. Read moreSource§fn or_filter<Predicate>(self, predicate: Predicate) -> OrFilter<Self, Predicate>where
Self: OrFilterDsl<Predicate>,
fn or_filter<Predicate>(self, predicate: Predicate) -> OrFilter<Self, Predicate>where
Self: OrFilterDsl<Predicate>,
Source§fn find<PK>(self, id: PK) -> Find<Self, PK>where
Self: FindDsl<PK>,
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>,
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>,
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>,
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 moreSource§fn limit(self, limit: i64) -> Limit<Self>where
Self: LimitDsl,
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,
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>,
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 moreSource§fn having<Predicate>(self, predicate: Predicate) -> Having<Self, Predicate>where
Self: HavingDsl<Predicate>,
fn having<Predicate>(self, predicate: Predicate) -> Having<Self, Predicate>where
Self: HavingDsl<Predicate>,
Adds to the
HAVING
clause of a query. Read moreSource§fn for_update(self) -> ForUpdate<Self>where
Self: LockingDsl<ForUpdate>,
fn for_update(self) -> ForUpdate<Self>where
Self: LockingDsl<ForUpdate>,
Adds
FOR UPDATE
to the end of the select statement. Read moreSource§fn for_no_key_update(self) -> ForNoKeyUpdate<Self>where
Self: LockingDsl<ForNoKeyUpdate>,
fn for_no_key_update(self) -> ForNoKeyUpdate<Self>where
Self: LockingDsl<ForNoKeyUpdate>,
Adds
FOR NO KEY UPDATE
to the end of the select statement. Read moreAdds
FOR SHARE
to the end of the select statement. Read moreAdds
FOR KEY SHARE
to the end of the select statement. Read moreSource§impl<S, DB> QueryFragment<DB> for Alias<S>
impl<S, DB> QueryFragment<DB> for Alias<S>
Source§fn walk_ast<'b>(&'b self, pass: AstPass<'_, 'b, DB>) -> QueryResult<()>
fn walk_ast<'b>(&'b self, pass: AstPass<'_, 'b, DB>) -> QueryResult<()>
Walk over this
QueryFragment
for all passes. Read moreSource§fn to_sql(&self, out: &mut DB::QueryBuilder, backend: &DB) -> QueryResult<()>
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 moreSource§fn collect_binds<'b>(
&'b self,
out: &mut DB::BindCollector<'b>,
metadata_lookup: &mut DB::MetadataLookup,
backend: &'b DB,
) -> QueryResult<()>
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>
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§impl<S, DB> QueryFragment<DB, AsAliasSyntax> for Alias<S>
impl<S, DB> QueryFragment<DB, AsAliasSyntax> for Alias<S>
Source§fn walk_ast<'b>(&'b self, pass: AstPass<'_, 'b, DB>) -> QueryResult<()>
fn walk_ast<'b>(&'b self, pass: AstPass<'_, 'b, DB>) -> QueryResult<()>
Walk over this
QueryFragment
for all passes. Read moreSource§fn to_sql(&self, out: &mut DB::QueryBuilder, backend: &DB) -> QueryResult<()>
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 moreSource§fn collect_binds<'b>(
&'b self,
out: &mut DB::BindCollector<'b>,
metadata_lookup: &mut DB::MetadataLookup,
backend: &'b DB,
) -> QueryResult<()>
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>
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§impl<S> QueryId for Alias<S>
impl<S> QueryId for Alias<S>
Source§const HAS_STATIC_QUERY_ID: bool = <S::Target as QueryId>::HAS_STATIC_QUERY_ID
const HAS_STATIC_QUERY_ID: bool = <S::Target as QueryId>::HAS_STATIC_QUERY_ID
Can the SQL generated by
Self
be uniquely identified by its type? Read moreSource§impl<S> QuerySource for Alias<S>where
Self: Clone,
S: AliasSource,
S::Target: QuerySource,
<S::Target as QuerySource>::DefaultSelection: FieldAliasMapper<S>,
<<S::Target as QuerySource>::DefaultSelection as FieldAliasMapper<S>>::Out: SelectableExpression<Self>,
impl<S> QuerySource for Alias<S>where
Self: Clone,
S: AliasSource,
S::Target: QuerySource,
<S::Target as QuerySource>::DefaultSelection: FieldAliasMapper<S>,
<<S::Target as QuerySource>::DefaultSelection as FieldAliasMapper<S>>::Out: SelectableExpression<Self>,
Source§type FromClause = Alias<S>
type FromClause = Alias<S>
The type returned by
from_clause
Source§type DefaultSelection = <<<S as AliasSource>::Target as QuerySource>::DefaultSelection as FieldAliasMapper<S>>::Out
type DefaultSelection = <<<S as AliasSource>::Target as QuerySource>::DefaultSelection as FieldAliasMapper<S>>::Out
The type returned by
default_selection
Source§fn from_clause(&self) -> Self::FromClause
fn from_clause(&self) -> Self::FromClause
The actual
FROM
clause of this type. This is typically only called in
QueryFragment
implementations.Source§fn default_selection(&self) -> Self::DefaultSelection
fn default_selection(&self) -> Self::DefaultSelection
The default select clause of this type, which should be used if no
select clause was explicitly specified. This should always be a tuple of
all the desired columns, not
star
Source§impl<S: AliasSource, Conn> RunQueryDsl<Conn> for Alias<S>
impl<S: AliasSource, Conn> RunQueryDsl<Conn> for Alias<S>
Source§fn execute(self, conn: &mut Conn) -> QueryResult<usize>where
Conn: Connection,
Self: ExecuteDsl<Conn>,
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>,
fn load<'query, U>(self, conn: &mut Conn) -> QueryResult<Vec<U>>where
Self: LoadQuery<'query, Conn, U>,
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,
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,
Source§fn get_result<'query, U>(self, conn: &mut Conn) -> QueryResult<U>where
Self: LoadQuery<'query, Conn, U>,
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>,
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 moreSource§impl<S, Expr> ThenOrderDsl<Expr> for Alias<S>
impl<S, Expr> ThenOrderDsl<Expr> for Alias<S>
impl<S: Copy> Copy for Alias<S>
impl<S2, S> JoinTo<Alias<S2>> for Alias<S>where
S2: AliasSource,
S: AliasSource + Default,
S::Target: JoinTo<Alias<S2>>,
<S::Target as JoinTo<Alias<S2>>>::OnClause: FieldAliasMapper<S>,
impl<T, S> JoinTo<T> for Alias<S>
impl<S, C> SelectableExpression<Alias<S>> for AliasedField<S, C>
Auto Trait Implementations§
impl<S> Freeze for Alias<S>where
S: Freeze,
impl<S> RefUnwindSafe for Alias<S>where
S: RefUnwindSafe,
impl<S> Send for Alias<S>where
S: Send,
impl<S> Sync for Alias<S>where
S: Sync,
impl<S> Unpin for Alias<S>where
S: Unpin,
impl<S> UnwindSafe for Alias<S>where
S: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more