Transform numbers into strings when faceted and necessary

This commit is contained in:
Clément Renault 2020-11-23 15:13:47 +01:00
parent fc686aaca7
commit 54d5cec582
No known key found for this signature in database
GPG Key ID: 92ADA4E935E71FA4

View File

@ -571,7 +571,10 @@ fn parse_facet_value(ftype: FacetType, value: &Value) -> anyhow::Result<SmallVec
Value::Null => Ok(()),
Value::Bool(b) => Ok(output.push(Integer(*b as i64))),
Value::Number(number) => match ftype {
FacetType::String => bail!("invalid facet type, expecting {} found number", ftype),
FacetType::String => {
let string = SmallString32::from(number.to_string());
Ok(output.push(String(string)))
},
FacetType::Float => match number.as_f64() {
Some(float) => Ok(output.push(Float(OrderedFloat(float)))),
None => bail!("invalid facet type, expecting {} found integer", ftype),