Struct diesel::query_source::Alias

source ·
pub struct Alias<S> { /* private fields */ }
Expand description

Represents an alias within diesel’s query builder

See alias! for more details.

Implementations§

source§

impl<S: AliasSource> Alias<S>

source

pub fn field<F>(&self, field: F) -> AliasedField<S, F>where F: Column<Table = S::Target>,

Maps a single field of the source table in this alias

source

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

§

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

§

type SqlType = <<Alias<S> as QuerySource>::DefaultSelection as Expression>::SqlType

The SQL type of Self::Query
§

type Query = SelectStatement<FromClause<Alias<S>>, DefaultSelectClause<FromClause<Alias<S>>>, NoDistinctClause, NoWhereClause, NoOrderClause, LimitOffsetClause<NoLimitClause, NoOffsetClause>, NoGroupByClause, NoHavingClause, NoLockingClause>

What kind of query does this type represent?
source§

fn as_query(self) -> Self::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<'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,

§

type Output = <SelectStatement<FromClause<Alias<S>>, DefaultSelectClause<FromClause<Alias<S>>>, NoDistinctClause, NoWhereClause, NoOrderClause, LimitOffsetClause<NoLimitClause, NoOffsetClause>, NoGroupByClause, NoHavingClause, NoLockingClause> as BoxedDsl<'a, DB>>::Output

The return type of internal_into_boxed
source§

fn internal_into_boxed(self) -> Self::Output

See the trait documentation.
source§

impl<S: Clone> Clone for Alias<S>

source§

fn clone(&self) -> Alias<S>

Returns a copy 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<S> CombineDsl for Alias<S>where S: AliasSource, S::Target: Table, Self: AsQuery,

§

type Query = <Alias<S> as AsQuery>::Query

What kind of query does this type represent?
source§

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

Combine two queries using a SQL EXCEPT ALL
source§

impl<S: Debug> Debug for Alias<S>

source§

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

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

impl<S: Default> Default for Alias<S>

source§

fn default() -> Alias<S>

Returns the “default value” for a type. Read more
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.
§

type Output = <SelectStatement<FromClause<Alias<S>>, DefaultSelectClause<FromClause<Alias<S>>>, NoDistinctClause, NoWhereClause, NoOrderClause, LimitOffsetClause<NoLimitClause, NoOffsetClause>, NoGroupByClause, NoHavingClause, NoLockingClause> as DistinctOnDsl<Selection>>::Output

The type returned by .distinct_on
source§

fn distinct_on(self, selection: Selection) -> DistinctOn<Self, Selection>

See the trait documentation
source§

impl<S, Predicate> FilterDsl<Predicate> for Alias<S>where Self: AsQuery, <Self as AsQuery>::Query: FilterDsl<Predicate>,

§

type Output = <<Alias<S> as AsQuery>::Query as FilterDsl<Predicate>>::Output

The type returned by .filter.
source§

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

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

§

type Output = <Alias<S> as FilterDsl<<<<<S as AliasSource>::Target as Table>::PrimaryKey as FieldAliasMapper<S>>::Out as EqAll<PK>>::Output>>::Output

The type returned by .find.
source§

fn find(self, id: PK) -> Self::Output

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

§

type Output = <SelectStatement<FromClause<Alias<S>>, DefaultSelectClause<FromClause<Alias<S>>>, NoDistinctClause, NoWhereClause, NoOrderClause, LimitOffsetClause<NoLimitClause, NoOffsetClause>, NoGroupByClause, NoHavingClause, NoLockingClause> as GroupByDsl<Expr>>::Output

The type returned by .group_by
source§

fn group_by(self, expr: Expr) -> GroupBy<Self, Expr>

See the trait documentation.
source§

impl<S> LimitDsl for Alias<S>where Self: AsQuery, <Self as AsQuery>::Query: LimitDsl,

§

type Output = <<Alias<S> as AsQuery>::Query as LimitDsl>::Output

The type returned by .limit
source§

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

See the trait documentation
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,

§

type Output = <SelectStatement<FromClause<Alias<S>>, DefaultSelectClause<FromClause<Alias<S>>>, NoDistinctClause, NoWhereClause, NoOrderClause, LimitOffsetClause<NoLimitClause, NoOffsetClause>, NoGroupByClause, NoHavingClause, NoLockingClause> as LockingDsl<Lock>>::Output

The type returned by set_lock. See dsl::ForUpdate and friends for convenient access to this type.
source§

fn with_lock(self, lock: Lock) -> Self::Output

See the trait level documentation
source§

impl<S> OffsetDsl for Alias<S>where Self: AsQuery, <Self as AsQuery>::Query: OffsetDsl,

§

type Output = <<Alias<S> as AsQuery>::Query as OffsetDsl>::Output

The type returned by .offset.
source§

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

See the trait documentation
source§

impl<S, Predicate> OrFilterDsl<Predicate> for Alias<S>where Self: AsQuery, <Self as AsQuery>::Query: OrFilterDsl<Predicate>,

§

type Output = <<Alias<S> as AsQuery>::Query as OrFilterDsl<Predicate>>::Output

The type returned by .filter.
source§

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

See the trait documentation.
source§

impl<S, Expr> OrderDsl<Expr> for Alias<S>where Expr: Expression, Self: AsQuery, <Self as AsQuery>::Query: OrderDsl<Expr>,

§

type Output = <<Alias<S> as AsQuery>::Query as OrderDsl<Expr>>::Output

The type returned by .order.
source§

fn order(self, expr: Expr) -> Self::Output

See the trait documentation.
source§

impl<S: AliasSource> QueryDsl for Alias<S>

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<S> QueryId for Alias<S>where Self: 'static, S: AliasSource, S::Target: QueryId,

§

type QueryId = Alias<S>

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

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

§

type FromClause = Alias<S>

The type returned by from_clause
§

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

The actual FROM clause of this type. This is typically only called in QueryFragment implementations.
source§

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>

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<S, Selection> SelectDsl<Selection> for Alias<S>where Selection: Expression, Self: AsQuery, <Self as AsQuery>::Query: SelectDsl<Selection>,

§

type Output = <<Alias<S> as AsQuery>::Query as SelectDsl<Selection>>::Output

The type returned by .select
source§

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

See the trait documentation
source§

impl<S, Expr> ThenOrderDsl<Expr> for Alias<S>where Expr: Expression, Self: AsQuery, <Self as AsQuery>::Query: ThenOrderDsl<Expr>,

§

type Output = <<Alias<S> as AsQuery>::Query as ThenOrderDsl<Expr>>::Output

The type returned by .then_order_by.
source§

fn then_order_by(self, expr: Expr) -> Self::Output

See the trait documentation.
source§

impl<S: Copy> Copy for Alias<S>

source§

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

source§

impl<T, S> JoinTo<T> for Alias<S>where T: Table, S: AliasSource + Default, S::Target: JoinTo<T>, <S::Target as JoinTo<T>>::OnClause: FieldAliasMapper<S>,

source§

impl<S, C> SelectableExpression<Alias<S>> for AliasedField<S, C>where S: AliasSource, C: Column<Table = S::Target>, Self: AppearsOnTable<Alias<S>>,

Auto Trait Implementations§

§

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> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere Conn: Connection<Backend = DB>, DB: Backend, T: QueryFragment<DB, NotSpecialized> + 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 Twhere 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>where Self: AsExpression<T> + Sized, T: SqlType + TypedExpressionType,

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> JoinOnDsl for Twhere T: QuerySource,

source§

fn on<On>(self, on: On) -> On<Self, On>

See the trait documentation.
source§

impl<T> ToOwned for Twhere T: Clone,

§

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 Twhere 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 Twhere 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 Twhere V: MultiLane<T>,

source§

fn vzip(self) -> V