diesel::helper_types

Type Alias When

Source
pub type When<W, C, T> = CaseWhen<CaseWhenConditionsIntermediateNode<Grouped<C>, Grouped<AsExprOf<T, <W as CaseWhenTypesExtractor>::OutputExpressionSpecifiedSqlType>>, <W as CaseWhenTypesExtractor>::Whens>, <W as CaseWhenTypesExtractor>::Else>;
Expand description

The return type of case_when(...).when(...)

Aliased Type§

struct When<W, C, T> { /* private fields */ }

Implementations

Source§

impl<Whens, E> CaseWhen<Whens, E>

Source

pub fn when<C, T>(self, condition: C, if_true: T) -> When<Self, C, T>
where Self: CaseWhenTypesExtractor<Whens = Whens, Else = E>, C: Expression, <C as Expression>::SqlType: BoolOrNullableBool, T: AsExpression<<Self as CaseWhenTypesExtractor>::OutputExpressionSpecifiedSqlType>,

Add an additional WHEN ... THEN ... branch to the CASE expression

See the case_when documentation for more details.

Source§

impl<Whens> CaseWhen<Whens, NoElseExpression>

Source

pub fn otherwise<E>(self, if_no_other_branch_matched: E) -> Otherwise<Self, E>
where Self: CaseWhenTypesExtractor<Whens = Whens, Else = NoElseExpression>, E: AsExpression<<Self as CaseWhenTypesExtractor>::OutputExpressionSpecifiedSqlType>,

Sets the ELSE branch of the CASE expression

It is named this way because else is a reserved keyword in Rust

See the case_when documentation for more details.

Trait Implementations

Source§

impl<Whens, E, __Rhs> Add<__Rhs> for CaseWhen<Whens, E>
where Self: Expression, <Self as Expression>::SqlType: Add, <<Self as Expression>::SqlType as Add>::Rhs: SqlType + SingleValue, __Rhs: AsExpression<<<Self as Expression>::SqlType as Add>::Rhs>,

Source§

type Output = Add<CaseWhen<Whens, E>, <__Rhs as AsExpression<<<CaseWhen<Whens, E> as Expression>::SqlType as Add>::Rhs>>::Expression>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: __Rhs) -> Self::Output

Performs the + operation. Read more
Source§

impl<Whens: Clone, E: Clone> Clone for CaseWhen<Whens, E>

Source§

fn clone(&self) -> CaseWhen<Whens, E>

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<Whens: Debug, E: Debug> Debug for CaseWhen<Whens, E>

Source§

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

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

impl<Whens, E, __Rhs> Div<__Rhs> for CaseWhen<Whens, E>
where Self: Expression, <Self as Expression>::SqlType: Div, <<Self as Expression>::SqlType as Div>::Rhs: SqlType + SingleValue, __Rhs: AsExpression<<<Self as Expression>::SqlType as Div>::Rhs>,

Source§

type Output = Div<CaseWhen<Whens, E>, <__Rhs as AsExpression<<<CaseWhen<Whens, E> as Expression>::SqlType as Div>::Rhs>>::Expression>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: __Rhs) -> Self::Output

Performs the / operation. Read more
Source§

impl<W, T, Whens, E> Expression for CaseWhen<CaseWhenConditionsIntermediateNode<W, T, Whens>, E>
where CaseWhen<CaseWhenConditionsLeaf<W, T>, E>: Expression, CaseWhen<Whens, E>: Expression<SqlType = <CaseWhen<CaseWhenConditionsLeaf<W, T>, E> as Expression>::SqlType>,

Source§

type SqlType = <CaseWhen<CaseWhenConditionsLeaf<W, T>, E> as Expression>::SqlType

The type that this expression represents in SQL
Source§

impl<Whens, E, __Rhs> Mul<__Rhs> for CaseWhen<Whens, E>
where Self: Expression, <Self as Expression>::SqlType: Mul, <<Self as Expression>::SqlType as Mul>::Rhs: SqlType + SingleValue, __Rhs: AsExpression<<<Self as Expression>::SqlType as Mul>::Rhs>,

Source§

type Output = Mul<CaseWhen<Whens, E>, <__Rhs as AsExpression<<<CaseWhen<Whens, E> as Expression>::SqlType as Mul>::Rhs>>::Expression>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: __Rhs) -> Self::Output

Performs the * operation. Read more
Source§

impl<Whens, E, DB> QueryFragment<DB> for CaseWhen<Whens, E>
where DB: Backend, Whens: QueryFragment<DB>, E: QueryFragment<DB>,

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<Whens: QueryId, E: QueryId> QueryId for CaseWhen<Whens, E>

Source§

const HAS_STATIC_QUERY_ID: bool = _

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

type QueryId = CaseWhen<<Whens as QueryId>::QueryId, <E as QueryId>::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<Whens, E, __Rhs> Sub<__Rhs> for CaseWhen<Whens, E>
where Self: Expression, <Self as Expression>::SqlType: Sub, <<Self as Expression>::SqlType as Sub>::Rhs: SqlType + SingleValue, __Rhs: AsExpression<<<Self as Expression>::SqlType as Sub>::Rhs>,

Source§

type Output = Sub<CaseWhen<Whens, E>, <__Rhs as AsExpression<<<CaseWhen<Whens, E> as Expression>::SqlType as Sub>::Rhs>>::Expression>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: __Rhs) -> Self::Output

Performs the - operation. Read more
Source§

impl<Whens, E, __GroupByClause> ValidGrouping<__GroupByClause> for CaseWhen<Whens, E>
where Whens: ValidGrouping<__GroupByClause>, E: ValidGrouping<__GroupByClause>, Whens::IsAggregate: MixedAggregates<E::IsAggregate>,

Source§

type IsAggregate = <<Whens as ValidGrouping<__GroupByClause>>::IsAggregate as MixedAggregates<<E as ValidGrouping<__GroupByClause>>::IsAggregate>>::Output

Is this expression aggregate? Read more
Source§

impl<W, T, Whens, E, QS> AppearsOnTable<QS> for CaseWhen<CaseWhenConditionsIntermediateNode<W, T, Whens>, E>
where Self: Expression, W: AppearsOnTable<QS>, T: AppearsOnTable<QS>, CaseWhen<Whens, E>: AppearsOnTable<QS>,

Source§

impl<Whens: Copy, E: Copy> Copy for CaseWhen<Whens, E>

Source§

impl<W, T, Whens, E, QS> SelectableExpression<QS> for CaseWhen<CaseWhenConditionsIntermediateNode<W, T, Whens>, E>