pub type case_when<C, T, ST = <T as Expression>::SqlType> = CaseWhen<CaseWhenConditionsLeaf<Grouped<C>, Grouped<AsExprOf<T, ST>>>, NoElseExpression>;
Expand description
The return type of case_when()
Aliased Type§
struct case_when<C, T, ST = <T as Expression>::SqlType> { /* 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> Expression for CaseWhen<CaseWhenConditionsLeaf<W, T>, NoElseExpression>where
W: Expression,
<W as Expression>::SqlType: BoolOrNullableBool,
T: Expression,
<T as Expression>::SqlType: IntoNullable,
<<T as Expression>::SqlType as IntoNullable>::Nullable: SqlType + TypedExpressionType,
impl<W, T> Expression for CaseWhen<CaseWhenConditionsLeaf<W, T>, NoElseExpression>where
W: Expression,
<W as Expression>::SqlType: BoolOrNullableBool,
T: Expression,
<T as Expression>::SqlType: IntoNullable,
<<T as Expression>::SqlType as IntoNullable>::Nullable: SqlType + TypedExpressionType,
source§type SqlType = <<T as Expression>::SqlType as IntoNullable>::Nullable
type SqlType = <<T as Expression>::SqlType as IntoNullable>::Nullable
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>,
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<()>
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<()>
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>
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