pub trait AggregatePolicy<D>: Numeric {
type Sum: DataType;
type Avg: DataType;
}Expand description
Result types of sum and avg for a numeric SQL type on dialect D.
| Dialect | Input | SUM | AVG |
|---|---|---|---|
| SQLite | INTEGER | INTEGER | REAL |
| SQLite | REAL | REAL | REAL |
| SQLite | NUMERIC, ANY | same as input | REAL |
| PostgreSQL | int2, int4 | int8 | float8 |
| PostgreSQL | int8 | int8 | float8 |
| PostgreSQL | float4, float8 | float8 | float8 |
| PostgreSQL | numeric | numeric | numeric |
| MySQL | integer types, DECIMAL | DECIMAL | DECIMAL |
| MySQL | FLOAT, DOUBLE | DOUBLE | DOUBLE |
These are the declared types; the SQL is not cast. PostgreSQL itself
returns numeric for AVG of an integer type and for SUM of int8,
and real for SUM of float4, so wrap such a result in
cast before decoding it.
Required Associated Types§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".