sea-query 1.0.1

🔱 A dynamic query builder for MySQL, Postgres and SQLite
Documentation
use super::*;

type_to_box_value!(BigDecimal, BigDecimal, Decimal(None));

impl NumericValue for BigDecimal {}
impl NumericValueNullable for Option<BigDecimal> {}

impl Value {
    pub fn is_big_decimal(&self) -> bool {
        matches!(self, Self::BigDecimal(_))
    }

    pub fn as_ref_big_decimal(&self) -> Option<&BigDecimal> {
        match self {
            Self::BigDecimal(v) => v.as_ref().map(|x| x.as_ref()),
            _ => panic!("not Value::BigDecimal"),
        }
    }

    pub fn big_decimal_to_f64(&self) -> Option<f64> {
        use bigdecimal::ToPrimitive;
        self.as_ref_big_decimal().map(|d| d.to_f64().unwrap())
    }
}