1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
#![cfg(feature = "bigdecimal")]

extern crate bigdecimal;

use self::bigdecimal::BigDecimal;

use deserialize::{self, FromSql};
use sql_types::{Double, Numeric};
use sqlite::connection::SqliteValue;
use sqlite::Sqlite;

impl FromSql<Numeric, Sqlite> for BigDecimal {
    fn from_sql(bytes: Option<&SqliteValue>) -> deserialize::Result<Self> {
        let data = <f64 as FromSql<Double, Sqlite>>::from_sql(bytes)?;
        Ok(data.into())
    }
}