Skip to content

Commit

Permalink
else_ -> otherwise
Browse files Browse the repository at this point in the history
  • Loading branch information
Ten0 committed Oct 24, 2023
1 parent c88e641 commit 6f45bae
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
10 changes: 6 additions & 4 deletions diesel/src/expression/case_when.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ use super::{AsExpression, TypedExpressionType};
/// use diesel::dsl::case_when;
///
/// let users_with_name: Vec<(i32, i32)> = users
/// .select((id, case_when(name.eq("Sean"), id).else_(0)))
/// .select((id, case_when(name.eq("Sean"), id).otherwise(0)))
/// .load(connection)
/// .unwrap();
///
Expand Down Expand Up @@ -117,8 +117,10 @@ impl<Whens, E> CaseWhen<Whens, E> {
impl<Whens> CaseWhen<Whens, NoElseExpression> {
/// 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.
pub fn else_<E>(self, if_no_other_branch_matched: E) -> helper_types::Else_<Self, E>
pub fn otherwise<E>(self, if_no_other_branch_matched: E) -> helper_types::Otherwise<Self, E>
where
Self: CaseWhenTypesExtractor<Whens = Whens, Else = NoElseExpression>,
E: AsExpression<<Self as CaseWhenTypesExtractor>::OutputExpressionSpecifiedSqlType>,
Expand Down Expand Up @@ -184,8 +186,8 @@ mod non_public_types {
pub(super) expr: E,
}

/// Largely internal trait used to define the [`When`] and [`Else_`] type
/// aliases
/// Largely internal trait used to define the [`When`] and [`Otherwise`]
/// type aliases
///
/// It should typically not be needed in user code unless writing extremely
/// generic functions
Expand Down
4 changes: 2 additions & 2 deletions diesel/src/expression/helper_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,8 @@ pub type When<W, C, T> = expression::case_when::CaseWhen<
>,
<W as expression::case_when::CaseWhenTypesExtractor>::Else,
>;
/// The return type of [`case_when(...).else_(...)`](expression::case_when::CaseWhen::else_)
pub type Else_<W, E> = expression::case_when::CaseWhen<
/// The return type of [`case_when(...).otherwise(...)`](expression::case_when::CaseWhen::otherwise)
pub type Otherwise<W, E> = expression::case_when::CaseWhen<
<W as expression::case_when::CaseWhenTypesExtractor>::Whens,
expression::case_when::ElseExpression<Grouped<AsExprOf<E, <W as expression::case_when::CaseWhenTypesExtractor>::OutputExpressionSpecifiedSqlType>>>,
>;
Expand Down

0 comments on commit 6f45bae

Please sign in to comment.