summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfdb-hiroshima <35889323+fdb-hiroshima@users.noreply.github.com>2019-08-08 13:41:04 +0200
committerPaul Masurel <paul.masurel@gmail.com>2019-08-08 20:41:04 +0900
commitbeb8e990cdfc199afc9f275e080271396e1847c7 (patch)
tree5cadc8f077c7f1e4ea5e2b3a056570a6432c6af3
parent001af3876fbd7a1318690d294c398b3147b6fcf2 (diff)
fix parsing neg float in range query (#621)
fix #620
-rw-r--r--src/query/query_parser/query_grammar.rs11
-rw-r--r--src/query/query_parser/query_parser.rs13
2 files changed, 22 insertions, 2 deletions
diff --git a/src/query/query_parser/query_grammar.rs b/src/query/query_parser/query_grammar.rs
index 51825a6..2ec2bf7 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<Item = char>]
{
- (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 d32546b..19993cc 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);
}