Skip to main content

mod_

Function mod_ 

Source
pub fn mod_<'a, V, E1, E2>(
    dividend: E1,
    divisor: E2,
) -> SQLExpr<'a, V, E1::SQLType, <E1::Nullable as Nullability>::Or<E2::Nullable>, <E1::Aggregate as AggregateKind>::Or<E2::Aggregate>, (E1::Sources, E2::Sources)>
where V: SQLParam + 'a, E1: Expr<'a, V>, E1::SQLType: Numeric, E2: Expr<'a, V>, E2::SQLType: Numeric, E2::Nullable: Nullability,
Expand description

Remainder of a division, rendered with the % operator.

Both arguments must be numeric. The result has the dividend’s SQL type and is nullable if either argument is. Named mod_ because mod is a Rust keyword. expr % n on an SQLExpr renders the same SQL, but types the result through ArithmeticOutput, which also marks it nullable on SQLite and MySQL (where x % 0 is NULL).

§Examples

assert_eq!(mod_(users.age, 10).sql(), r#""users"."age" % ?"#);