Skip to content

Commit

Permalink
Replace f64->Decimal conversion with f64->String->Decimal
Browse files Browse the repository at this point in the history
It appears to be a bug in rust_decimal. Issue link: paupino/rust-decimal#228
  • Loading branch information
tomhoule committed Mar 10, 2020
1 parent 97e8021 commit 411a83c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Expand Up @@ -327,7 +327,7 @@ async fn all_postgres_column_types_must_work() {
name: "interval_col".into(),
tpe: ColumnType {
raw: "interval".into(),
family: ColumnTypeFamily::DateTime,
family: ColumnTypeFamily::String,
arity: ColumnArity::Required,
},

Expand Down
Expand Up @@ -3,8 +3,8 @@ use graphql_parser::query::{
Definition, Document, OperationDefinition, Selection as GqlSelection, SelectionSet, Value,
};
use query_core::query_document::*;
use rust_decimal::{prelude::FromPrimitive, Decimal};
use std::collections::BTreeMap;
use rust_decimal::Decimal;
use std::{collections::BTreeMap, str::FromStr};

/// Protocol adapter for GraphQL -> Query Document.
///
Expand Down Expand Up @@ -145,7 +145,7 @@ impl GraphQLProtocolAdapter {
i
))),
},
Value::Float(f) => match Decimal::from_f64(f) {
Value::Float(f) => match Decimal::from_str(&f.to_string()).ok() {
Some(dec) => Ok(QueryValue::Float(dec)),
None => Err(PrismaError::QueryConversionError(format!(
"invalid 64-bit float: {:?}",
Expand Down

0 comments on commit 411a83c

Please sign in to comment.