diff --git a/filter-parser/src/value.rs b/filter-parser/src/value.rs index abdc10439..d08a12a92 100644 --- a/filter-parser/src/value.rs +++ b/filter-parser/src/value.rs @@ -6,7 +6,10 @@ use nom::sequence::{delimited, terminated}; use nom::{InputIter, InputLength, InputTake, Slice}; use crate::error::{ExpectedValueKind, NomErrorExt}; -use crate::{parse_geo_point, parse_geo_radius, parse_geo_bounding_box, Error, ErrorKind, IResult, Span, Token}; +use crate::{ + parse_geo_bounding_box, parse_geo_point, parse_geo_radius, Error, ErrorKind, IResult, Span, + Token, +}; /// This function goes through all characters in the [Span] if it finds any escaped character (`\`). /// It generates a new string with all `\` removed from the [Span]. @@ -91,7 +94,9 @@ pub fn parse_value(input: Span) -> IResult { } } match parse_geo_radius(input) { - Ok(_) => return Err(nom::Err::Failure(Error::new_from_kind(input, ErrorKind::MisusedGeoRadius))), + Ok(_) => { + return Err(nom::Err::Failure(Error::new_from_kind(input, ErrorKind::MisusedGeoRadius))) + } // if we encountered a failure it means the user badly wrote a _geoRadius filter. // But instead of showing him how to fix his syntax we are going to tell him he should not use this filter as a value. Err(e) if e.is_failure() => { @@ -101,11 +106,19 @@ pub fn parse_value(input: Span) -> IResult { } match parse_geo_bounding_box(input) { - Ok(_) => return Err(nom::Err::Failure(Error::new_from_kind(input, ErrorKind::MisusedGeoBoundingBox))), + Ok(_) => { + return Err(nom::Err::Failure(Error::new_from_kind( + input, + ErrorKind::MisusedGeoBoundingBox, + ))) + } // if we encountered a failure it means the user badly wrote a _geoBoundingBox filter. // But instead of showing him how to fix his syntax we are going to tell him he should not use this filter as a value. Err(e) if e.is_failure() => { - return Err(nom::Err::Failure(Error::new_from_kind(input, ErrorKind::MisusedGeoBoundingBox))) + return Err(nom::Err::Failure(Error::new_from_kind( + input, + ErrorKind::MisusedGeoBoundingBox, + ))) } _ => (), } diff --git a/milli/src/asc_desc.rs b/milli/src/asc_desc.rs index 444819c34..ebb28c27d 100644 --- a/milli/src/asc_desc.rs +++ b/milli/src/asc_desc.rs @@ -92,7 +92,10 @@ impl FromStr for Member { Ok(Member::Geo([lat, lng])) } None => { - if is_reserved_keyword(text) || text.starts_with("_geoRadius(") || text.starts_with("_geoBoundingBox(") { + if is_reserved_keyword(text) + || text.starts_with("_geoRadius(") + || text.starts_with("_geoBoundingBox(") + { return Err(AscDescError::ReservedKeyword { name: text.to_string() })?; } Ok(Member::Field(text.to_string())) diff --git a/milli/src/criterion.rs b/milli/src/criterion.rs index 23e2ac7f1..9a6e2be4a 100644 --- a/milli/src/criterion.rs +++ b/milli/src/criterion.rs @@ -160,7 +160,10 @@ mod tests { ("_geoRadius:asc", ReservedNameForFilter { name: S("_geoRadius") }), ("_geoRadius(42, 75, 59):asc", ReservedNameForFilter { name: S("_geoRadius") }), ("_geoBoundingBox:asc", ReservedNameForFilter { name: S("_geoBoundingBox") }), - ("_geoBoundingBox((42, 75), (75, 59)):asc", ReservedNameForFilter { name: S("_geoBoundingBox") }), + ( + "_geoBoundingBox((42, 75), (75, 59)):asc", + ReservedNameForFilter { name: S("_geoBoundingBox") }, + ), ]; for (input, expected) in invalid_criteria {