Fix decimal decoding (#3907)
This commit is contained in:
parent
2e840bbcb6
commit
982e6b33fd
1 changed files with 3 additions and 1 deletions
|
@ -1,6 +1,7 @@
|
|||
use ciborium::Value as Data;
|
||||
use geo::{LineString, Point, Polygon};
|
||||
use geo_types::{MultiLineString, MultiPoint, MultiPolygon};
|
||||
use rust_decimal::Decimal;
|
||||
use std::iter::once;
|
||||
use std::ops::Deref;
|
||||
|
||||
|
@ -12,6 +13,7 @@ use crate::sql::Number;
|
|||
use crate::sql::Thing;
|
||||
use crate::sql::Uuid;
|
||||
use crate::sql::Value;
|
||||
use std::str::FromStr;
|
||||
|
||||
// Tags from the spec - https://www.iana.org/assignments/cbor-tags/cbor-tags.xhtml
|
||||
const TAG_SPEC_DATETIME: u64 = 0;
|
||||
|
@ -119,7 +121,7 @@ impl TryFrom<Cbor> for Value {
|
|||
},
|
||||
// A literal decimal
|
||||
TAG_STRING_DECIMAL => match *v {
|
||||
Data::Text(v) => match Number::try_from(v) {
|
||||
Data::Text(v) => match Decimal::from_str(v.as_str()) {
|
||||
Ok(v) => Ok(v.into()),
|
||||
_ => Err("Expected a valid Decimal value"),
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue