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>
impl<Whens, E> CaseWhen<Whens, E>
Sourcepub 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>,
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>
impl<Whens> CaseWhen<Whens, NoElseExpression>
Sourcepub 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>,
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>,
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§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>,
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§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>,
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§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>,
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§impl<Whens, E, DB> QueryFragment<DB> for CaseWhen<Whens, E>
impl<Whens, E, DB> QueryFragment<DB> for CaseWhen<Whens, E>
Source§fn walk_ast<'b>(&'b self, out: AstPass<'_, 'b, DB>) -> QueryResult<()>
fn walk_ast<'b>(&'b self, out: 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<Whens: QueryId, E: QueryId> QueryId for CaseWhen<Whens, E>
impl<Whens: QueryId, E: QueryId> QueryId for CaseWhen<Whens, E>
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>,
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§impl<Whens, E, __GroupByClause> ValidGrouping<__GroupByClause> for CaseWhen<Whens, E>where
Whens: ValidGrouping<__GroupByClause>,
E: ValidGrouping<__GroupByClause>,
Whens::IsAggregate: MixedAggregates<E::IsAggregate>,
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
type IsAggregate = <<Whens as ValidGrouping<__GroupByClause>>::IsAggregate as MixedAggregates<<E as ValidGrouping<__GroupByClause>>::IsAggregate>>::Output
Is this expression aggregate? Read more