Change method signature of expr_as
to accept self
#1979
This commit is contained in:
parent
8aa49beb6d
commit
d471c4e022
@ -511,6 +511,8 @@ pub trait QuerySelect: Sized {
|
|||||||
/// "SELECT `cake`.`id`, `cake`.`name`, UPPER(`cake`.`name`) AS `name_upper` FROM `cake`"
|
/// "SELECT `cake`.`id`, `cake`.`name`, UPPER(`cake`.`name`) AS `name_upper` FROM `cake`"
|
||||||
/// );
|
/// );
|
||||||
/// ```
|
/// ```
|
||||||
|
///
|
||||||
|
/// FIXME: change signature to `mut self`
|
||||||
fn expr_as<T, A>(&mut self, expr: T, alias: A) -> &mut Self
|
fn expr_as<T, A>(&mut self, expr: T, alias: A) -> &mut Self
|
||||||
where
|
where
|
||||||
T: Into<SimpleExpr>,
|
T: Into<SimpleExpr>,
|
||||||
@ -519,6 +521,34 @@ pub trait QuerySelect: Sized {
|
|||||||
self.query().expr_as(expr, alias.into_identity());
|
self.query().expr_as(expr, alias.into_identity());
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Owned version of `expr_as`.
|
||||||
|
///
|
||||||
|
/// Select column.
|
||||||
|
///
|
||||||
|
/// ```
|
||||||
|
/// use sea_orm::sea_query::{Alias, Expr, Func};
|
||||||
|
/// use sea_orm::{entity::*, tests_cfg::cake, DbBackend, QuerySelect, QueryTrait};
|
||||||
|
///
|
||||||
|
/// assert_eq!(
|
||||||
|
/// cake::Entity::find()
|
||||||
|
/// .expr_as(
|
||||||
|
/// Func::upper(Expr::col((cake::Entity, cake::Column::Name))),
|
||||||
|
/// "name_upper"
|
||||||
|
/// )
|
||||||
|
/// .build(DbBackend::MySql)
|
||||||
|
/// .to_string(),
|
||||||
|
/// "SELECT `cake`.`id`, `cake`.`name`, UPPER(`cake`.`name`) AS `name_upper` FROM `cake`"
|
||||||
|
/// );
|
||||||
|
/// ```
|
||||||
|
fn expr_as_<T, A>(mut self, expr: T, alias: A) -> Self
|
||||||
|
where
|
||||||
|
T: Into<SimpleExpr>,
|
||||||
|
A: IntoIdentity,
|
||||||
|
{
|
||||||
|
self.query().expr_as(expr, alias.into_identity());
|
||||||
|
self
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// LINT: when the column does not appear in tables selected from
|
// LINT: when the column does not appear in tables selected from
|
||||||
|
Loading…
x
Reference in New Issue
Block a user