Skip to content

Commit

Permalink
SQLite bind rust_decimal & bigdecimal as f64 (#480)
Browse files Browse the repository at this point in the history
* SQLite bind `rust_decimal` & `bigdecimal` as f64

* Use expect over unwrap
  • Loading branch information
billy1624 authored Oct 17, 2022
1 parent 1afbde4 commit 890e22c
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions sea-query-binder/src/sqlx_sqlite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,18 @@ impl<'q> sqlx::IntoArguments<'q, sqlx::sqlite::Sqlite> for SqlxValues {
args.add(uuid.map(|uuid| *uuid));
}
#[cfg(feature = "with-rust_decimal")]
Value::Decimal(_) => {
panic!("Sqlite doesn't support decimal arguments");
Value::Decimal(decimal) => {
use rust_decimal::prelude::ToPrimitive;
args.add(
decimal.map(|d| d.to_f64().expect("Fail to convert rust_decimal as f64")),
);
}
#[cfg(feature = "with-bigdecimal")]
Value::BigDecimal(_) => {
panic!("Sqlite doesn't support bigdecimal arguments");
Value::BigDecimal(big_decimal) => {
use bigdecimal::ToPrimitive;
args.add(
big_decimal.map(|d| d.to_f64().expect("Fail to convert bigdecimal as f64")),
);
}
#[cfg(feature = "with-json")]
Value::Json(j) => {
Expand Down

0 comments on commit 890e22c

Please sign in to comment.