pub struct CaseWhen<Whens, E> { /* private fields */ }
Expand description
A SQL CASE WHEN ... END
expression
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<W, T, E> Expression for CaseWhen<CaseWhenConditionsLeaf<W, T>, ElseExpression<E>>
impl<W, T, E> Expression for CaseWhen<CaseWhenConditionsLeaf<W, T>, ElseExpression<E>>
Source§type SqlType = <T as Expression>::SqlType
type SqlType = <T as Expression>::SqlType
The type that this expression represents in SQL
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§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
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>,
impl<W, T, E, QS> AppearsOnTable<QS> for CaseWhen<CaseWhenConditionsLeaf<W, T>, ElseExpression<E>>where
CaseWhen<CaseWhenConditionsLeaf<W, T>, ElseExpression<E>>: Expression,
W: AppearsOnTable<QS>,
T: AppearsOnTable<QS>,
E: AppearsOnTable<QS>,
impl<W, T, QS> AppearsOnTable<QS> for CaseWhen<CaseWhenConditionsLeaf<W, T>, NoElseExpression>where
CaseWhen<CaseWhenConditionsLeaf<W, T>, NoElseExpression>: Expression,
W: AppearsOnTable<QS>,
T: AppearsOnTable<QS>,
impl<Whens: Copy, E: Copy> Copy for CaseWhen<Whens, E>
impl<W, T, Whens, E, QS> SelectableExpression<QS> for CaseWhen<CaseWhenConditionsIntermediateNode<W, T, Whens>, E>where
Self: AppearsOnTable<QS>,
W: SelectableExpression<QS>,
T: SelectableExpression<QS>,
CaseWhen<Whens, E>: SelectableExpression<QS>,
impl<W, T, E, QS> SelectableExpression<QS> for CaseWhen<CaseWhenConditionsLeaf<W, T>, ElseExpression<E>>where
CaseWhen<CaseWhenConditionsLeaf<W, T>, ElseExpression<E>>: AppearsOnTable<QS>,
W: SelectableExpression<QS>,
T: SelectableExpression<QS>,
E: SelectableExpression<QS>,
impl<W, T, QS> SelectableExpression<QS> for CaseWhen<CaseWhenConditionsLeaf<W, T>, NoElseExpression>where
CaseWhen<CaseWhenConditionsLeaf<W, T>, NoElseExpression>: AppearsOnTable<QS>,
W: SelectableExpression<QS>,
T: SelectableExpression<QS>,
Auto Trait Implementations§
impl<Whens, E> Freeze for CaseWhen<Whens, E>
impl<Whens, E> RefUnwindSafe for CaseWhen<Whens, E>where
Whens: RefUnwindSafe,
E: RefUnwindSafe,
impl<Whens, E> Send for CaseWhen<Whens, E>
impl<Whens, E> Sync for CaseWhen<Whens, E>
impl<Whens, E> Unpin for CaseWhen<Whens, E>
impl<Whens, E> UnwindSafe for CaseWhen<Whens, E>where
Whens: UnwindSafe,
E: UnwindSafe,
Blanket Implementations§
Source§impl<T, ST> AsExpression<ST> for T
impl<T, ST> AsExpression<ST> for T
Source§type Expression = T
type Expression = T
The expression being returned
Source§fn as_expression(self) -> T
fn as_expression(self) -> T
Perform the conversion
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Conn, DB, T> ExecuteDsl<Conn, DB> for T
impl<Conn, DB, T> ExecuteDsl<Conn, DB> for T
Source§impl<T> IntoSql for T
impl<T> IntoSql for T
Source§impl<T> NullableExpressionMethods for Twhere
T: Expression,
impl<T> NullableExpressionMethods for Twhere
T: Expression,
Source§fn nullable(self) -> Nullable<Self>
fn nullable(self) -> Nullable<Self>
Converts this potentially non-null expression into one which is treated
as nullable. This method has no impact on the generated SQL, and is only
used to allow certain comparisons that would otherwise fail to compile. Read more
Source§fn assume_not_null(self) -> AssumeNotNull<Self>
fn assume_not_null(self) -> AssumeNotNull<Self>
Converts this potentially nullable expression into one which will be assumed
to be not-null. This method has no impact on the generated SQL, however it will
enable you to attempt deserialization of the returned value in a non-
Option
. Read moreSource§impl<T> PgExpressionMethods for Twhere
T: Expression,
impl<T> PgExpressionMethods for Twhere
T: Expression,
Source§fn is_not_distinct_from<T>(self, other: T) -> IsNotDistinctFrom<Self, T>
fn is_not_distinct_from<T>(self, other: T) -> IsNotDistinctFrom<Self, T>
Available on crate feature
postgres_backend
only.Creates a PostgreSQL
IS NOT DISTINCT FROM
expression. Read moreSource§fn is_distinct_from<T>(self, other: T) -> IsDistinctFrom<Self, T>
fn is_distinct_from<T>(self, other: T) -> IsDistinctFrom<Self, T>
Available on crate feature
postgres_backend
only.Creates a PostgreSQL
IS DISTINCT FROM
expression. Read more