Skip to main content

CaseBuilder

Struct CaseBuilder 

Source
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>
where V: SQLParam + 'a, T: DataType, N: Nullability, A: AggregateKind,

Source

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>

Add another WHEN branch.

The result type must be compatible with the type established by the first branch. Nullability is accumulated via NullOr.

Source

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.

Source

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>
where V: Send + Sync, T: Send, N: Send, A: Send,

§

impl<'a, V, T, N, A> Sync for CaseBuilder<'a, V, T, N, A>
where V: Sync, T: Sync, N: Sync, A: Sync,

§

impl<'a, V, T, N, A> Unpin for CaseBuilder<'a, V, T, N, A>
where V: Unpin, T: Unpin, N: Unpin, A: Unpin,

§

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> AliasExt for T

Source§

fn alias(self, name: &'static str) -> AliasedExpr<Self>

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<Mk> MarkerAggValidFor<()> for Mk

Source§

impl<Scope> ScopeSatisfies<Nil, ()> for Scope

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> TypeEq<T> for T