diff --git a/src/query/query_parser/query_grammar.rs b/src/query/query_parser/query_grammar.rs index 51825a637..2ec2bf7d0 100644 --- a/src/query/query_parser/query_grammar.rs +++ b/src/query/query_parser/query_grammar.rs @@ -63,8 +63,15 @@ parser! { fn negative_number[I]()(I) -> String where [I: Stream] { - (char('-'), many1(satisfy(char::is_numeric))) - .map(|(s1, s2): (char, String)| format!("{}{}", s1, s2)) + (char('-'), many1(satisfy(char::is_numeric)), + optional((char('.'), many1(satisfy(char::is_numeric))))) + .map(|(s1, s2, s3): (char, String, Option<(char, String)>)| { + if let Some(('.', s3)) = s3 { + format!("{}{}.{}", s1, s2, s3) + } else { + format!("{}{}", s1, s2) + } + }) } } diff --git a/src/query/query_parser/query_parser.rs b/src/query/query_parser/query_parser.rs index d32546b38..19993cc43 100644 --- a/src/query/query_parser/query_parser.rs +++ b/src/query/query_parser/query_parser.rs @@ -765,6 +765,19 @@ mod test { "(Excluded(Term([0, 0, 0, 0, 116, 105, 116, 105])) TO Unbounded)", false, ); + test_parse_query_to_logical_ast_helper( + "signed:{-5 TO 3}", + "(Excluded(Term([0, 0, 0, 2, 127, 255, 255, 255, 255, 255, 255, 251])) TO \ + Excluded(Term([0, 0, 0, 2, 128, 0, 0, 0, 0, 0, 0, 3])))", + false, + ); + test_parse_query_to_logical_ast_helper( + "float:{-1.5 TO 1.5}", + "(Excluded(Term([0, 0, 0, 10, 64, 7, 255, 255, 255, 255, 255, 255])) TO \ + Excluded(Term([0, 0, 0, 10, 191, 248, 0, 0, 0, 0, 0, 0])))", + false, + ); + test_parse_query_to_logical_ast_helper("*", "*", false); }