Skip to main content

abs

Function abs 

Source
pub fn abs<'a, V, E>(
    expr: E,
) -> SQLExpr<'a, V, E::SQLType, E::Nullable, E::Aggregate, E::Sources>
where V: SQLParam + 'a, E: Expr<'a, V>, E::SQLType: Numeric,
Expand description

Absolute value (ABS).

The argument must be numeric. The result keeps the argument’s SQL type, nullability and aggregate kind.

§Examples

assert_eq!(abs(users.score).sql(), r#"ABS ("users"."score")"#);

§Type safety

ABS of a text column does not compile:

ⓘ
let wrong = abs(users.name);