pub trait RoundingPolicy<D>: Numeric {
type Output: DataType;
// Provided methods
fn precision_operand<'a, V: SQLParam + 'a>(expr: SQL<'a, V>) -> SQL<'a, V> { ... }
fn coerce_result<'a, V: SQLParam + 'a>(sql: SQL<'a, V>) -> SQL<'a, V> { ... }
}Expand description
Result type of round, round_to, ceil, floor and trunc
for a numeric SQL type on dialect D.
| Dialect | Input | Result |
|---|---|---|
| SQLite | any numeric | REAL |
| PostgreSQL | any numeric | float8 (the call is cast to DOUBLE PRECISION) |
| MySQL | signed integers | BIGINT |
| MySQL | unsigned integers, YEAR | BIGINT UNSIGNED |
| MySQL | FLOAT, DOUBLE | DOUBLE |
| MySQL | DECIMAL | DECIMAL |
Required Associated Types§
Provided Methods§
Sourcefn precision_operand<'a, V: SQLParam + 'a>(expr: SQL<'a, V>) -> SQL<'a, V>
fn precision_operand<'a, V: SQLParam + 'a>(expr: SQL<'a, V>) -> SQL<'a, V>
Prepares the operand of ROUND(expr, precision).
PostgreSQL only defines the two-argument ROUND for numeric, and
double precision does not cast to it implicitly.
Sourcefn coerce_result<'a, V: SQLParam + 'a>(sql: SQL<'a, V>) -> SQL<'a, V>
fn coerce_result<'a, V: SQLParam + 'a>(sql: SQL<'a, V>) -> SQL<'a, V>
Coerces a rounding function’s result to Self::Output.
PostgreSQL returns numeric for every rounding function unless the
argument is double precision; the declared output is float8.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".