sea_query/value/
with_bigdecimal.rs

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