Skip to main content

convert_value

Function convert_value 

Source
pub fn convert_value(val: &Value) -> Result<SqlValue>
Expand description

Convert a sqlparser Value to our SqlValue.

Number literal routing:

  • Integers in i64 range → SqlValue::Int.
  • Larger integers → SqlValue::Decimal, exact. A u64 above i64::MAX is the Decimal Value::from_u64 gives it, so it is written as a msgpack uint64. An integer past the Decimal range is SqlError::NumericLiteralOutOfRange: rounding it to a float would store another number than the one written.
  • Numbers with an exponent (e or E) → SqlValue::Float. A bound float parameter renders in this form, so it stays a float.
  • Other numbers with . → SqlValue::Decimal (exact arithmetic).
  • If decimal parse fails → fallback to SqlValue::Float, then SqlValue::String.