handle the case where you forgot entirely the parenthesis

This commit is contained in:
Tamo 2021-09-06 17:28:49 +02:00
parent ebf82ac28c
commit 6d5762a6c8
No known key found for this signature in database
GPG Key ID: 20CD8020AFA88D69
2 changed files with 7 additions and 1 deletions

View File

@ -797,6 +797,12 @@ mod tests {
); );
assert_eq!(condition, expected); assert_eq!(condition, expected);
// georadius don't have any parameters
let result = FilterCondition::from_str(&rtxn, &index, "_geoRadius");
assert!(result.is_err());
let error = result.unwrap_err();
assert!(error.to_string().contains("The `_geoRadius` filter expect three arguments: `_geoRadius(latitude, longitude, radius)`"));
// georadius don't have any parameters // georadius don't have any parameters
let result = FilterCondition::from_str(&rtxn, &index, "_geoRadius()"); let result = FilterCondition::from_str(&rtxn, &index, "_geoRadius()");
assert!(result.is_err()); assert!(result.is_err());

View File

@ -9,7 +9,7 @@ char = _{ !(PEEK | "\\") ~ ANY
| "\\" ~ ("u" ~ ASCII_HEX_DIGIT{4})} | "\\" ~ ("u" ~ ASCII_HEX_DIGIT{4})}
// we deliberately choose to allow empty parameters to generate more specific error message later // we deliberately choose to allow empty parameters to generate more specific error message later
parameters ={"(" ~ (value ~ ",")* ~ value? ~ ")"} parameters ={("(" ~ (value ~ ",")* ~ value? ~ ")") | ""}
condition = _{between | eq | greater | less | geq | leq | neq} condition = _{between | eq | greater | less | geq | leq | neq}
between = {key ~ value ~ "TO" ~ value} between = {key ~ value ~ "TO" ~ value}
geq = {key ~ ">=" ~ value} geq = {key ~ ">=" ~ value}