pub struct CaseBuilder<'a, V: SQLParam, T: DataType, N: Nullability, A: AggregateKind> { /* private fields */ }Expand description
Builder state after at least one WHEN branch has been added.
The result type T and accumulated nullability N are tracked.
Implementations§
Source§impl<'a, V, T, N, A> CaseBuilder<'a, V, T, N, A>
impl<'a, V, T, N, A> CaseBuilder<'a, V, T, N, A>
Sourcepub fn when<C, R>(
self,
condition: C,
result: R,
) -> CaseBuilder<'a, V, T, <N as NullOr<R::Nullable>>::Output, <<A as AggOr<C::Aggregate>>::Output as AggOr<R::Aggregate>>::Output>where
C: Expr<'a, V>,
R: Expr<'a, V>,
C::SQLType: BooleanLike,
T: Compatible<R::SQLType>,
N: NullOr<R::Nullable>,
R::Nullable: Nullability,
A: AggOr<C::Aggregate>,
<A as AggOr<C::Aggregate>>::Output: AggOr<R::Aggregate>,
C::Aggregate: AggregateKind,
R::Aggregate: AggregateKind,
pub fn when<C, R>(
self,
condition: C,
result: R,
) -> CaseBuilder<'a, V, T, <N as NullOr<R::Nullable>>::Output, <<A as AggOr<C::Aggregate>>::Output as AggOr<R::Aggregate>>::Output>where
C: Expr<'a, V>,
R: Expr<'a, V>,
C::SQLType: BooleanLike,
T: Compatible<R::SQLType>,
N: NullOr<R::Nullable>,
R::Nullable: Nullability,
A: AggOr<C::Aggregate>,
<A as AggOr<C::Aggregate>>::Output: AggOr<R::Aggregate>,
C::Aggregate: AggregateKind,
R::Aggregate: AggregateKind,
Add another WHEN branch.
The result type must be compatible with the type established by the
first branch. Nullability is accumulated via NullOr.
Sourcepub fn end(self) -> SQLExpr<'a, V, T, Null, A>
pub fn end(self) -> SQLExpr<'a, V, T, Null, A>
Finish the CASE expression without an ELSE clause.
Without ELSE, unmatched rows produce NULL, so the result is always
Null regardless of branch nullability.
Sourcepub fn else<D>(
self,
default: D,
) -> SQLExpr<'a, V, T, <N as NullOr<D::Nullable>>::Output, <A as AggOr<D::Aggregate>>::Output>where
D: Expr<'a, V>,
T: Compatible<D::SQLType>,
N: NullOr<D::Nullable>,
D::Nullable: Nullability,
A: AggOr<D::Aggregate>,
D::Aggregate: AggregateKind,
pub fn else<D>(
self,
default: D,
) -> SQLExpr<'a, V, T, <N as NullOr<D::Nullable>>::Output, <A as AggOr<D::Aggregate>>::Output>where
D: Expr<'a, V>,
T: Compatible<D::SQLType>,
N: NullOr<D::Nullable>,
D::Nullable: Nullability,
A: AggOr<D::Aggregate>,
D::Aggregate: AggregateKind,
Finish the CASE expression with an ELSE clause.
The ELSE value must have a compatible type. Nullability is the combination of all branch nullabilities and the default’s nullability.
Auto Trait Implementations§
impl<'a, V, T, N, A> Freeze for CaseBuilder<'a, V, T, N, A>where
V: Freeze,
impl<'a, V, T, N, A> RefUnwindSafe for CaseBuilder<'a, V, T, N, A>
impl<'a, V, T, N, A> Send for CaseBuilder<'a, V, T, N, A>
impl<'a, V, T, N, A> Sync for CaseBuilder<'a, V, T, N, A>
impl<'a, V, T, N, A> Unpin for CaseBuilder<'a, V, T, N, A>
impl<'a, V, T, N, A> UnsafeUnpin for CaseBuilder<'a, V, T, N, A>where
V: UnsafeUnpin,
impl<'a, V, T, N, A> UnwindSafe for CaseBuilder<'a, V, T, N, A>
Blanket Implementations§
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