sea_query/value/
with_bigdecimal.rs

1use super::*;
2
3type_to_value!(BigDecimal, BigDecimal, Decimal(None));
4
5impl NumericValue for BigDecimal {}
6impl NumericValueNullable for Option<BigDecimal> {}
7
8impl Value {
9    pub fn is_big_decimal(&self) -> bool {
10        matches!(self, Self::BigDecimal(_))
11    }
12
13    pub fn as_ref_big_decimal(&self) -> Option<&BigDecimal> {
14        match self {
15            Self::BigDecimal(v) => v.as_ref(),
16            _ => panic!("not Value::BigDecimal"),
17        }
18    }
19
20    pub fn big_decimal_to_f64(&self) -> Option<f64> {
21        use bigdecimal::ToPrimitive;
22        self.as_ref_big_decimal().map(|d| d.to_f64().unwrap())
23    }
24}