pub fn numeric(value: Decimal, precision: u8, scale: u8) -> NumericExpand description
Create a decimal/numeric parameter with explicit precision and scale.
Required when binding to an Always Encrypted decimal column, whose declared
decimal(precision, scale) must match the column exactly.
numeric(value, precision, scale) asserts that value fits the
decimal(precision, scale) domain, and ToSql::to_sql enforces that
assertion on every path — encrypted or plaintext (it is the caller’s
declared domain, not a property of the connection). It errors when:
precisionis outside1..=38, orscale > precision;scale > 28—rust_decimal::Decimalcaps its backing scale at 28, so a larger declared scale cannot be represented and, on the Always Encrypted path, would emit a magnitude a Microsoft client reads at the wrong scale (e.g.0.5→0.005) with no server backstop. The driver’sdecimalAlways Encrypted support is therefore bounded toscale ≤ 28;- the value, after rescaling, has more significant digits than
precision.
The value is rescaled to scale, which rounds when the value has more
fractional digits than scale (e.g. numeric(dec!(12.999), 18, 2) stores
13.00).