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>
where V: SQLParam + 'a, E: Expr<'a, V>, E::SQLType: Numeric,
Expand description

ABS - returns the absolute value of a number.

Preserves the SQL type and nullability of the input expression.

§Type Safety

// ✅ OK: Int column
abs(users.balance);

// ❌ Compile error: Text is not Numeric
abs(users.name);