Skip to content

Commit fd0896d

Browse files
committed
feat: Support spaces between field name and value
1 parent 811c68c commit fd0896d

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

query-grammar/src/query_grammar.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ fn field_name(inp: &str) -> IResult<&str, String> {
3636
alt((first_char, escape_sequence())),
3737
many0(alt((simple_char, escape_sequence(), char('\\')))),
3838
)),
39-
char(':'),
39+
tuple((char(':'), multispace0)),
4040
),
4141
|(first_char, next)| once(first_char).chain(next).collect(),
4242
)(inp)
@@ -1283,6 +1283,10 @@ mod test {
12831283
super::field_name("~my~field:a"),
12841284
Ok(("a", "~my~field".to_string()))
12851285
);
1286+
assert_eq!(
1287+
super::field_name(".my.field.name: a"),
1288+
Ok(("a", ".my.field.name".to_string()))
1289+
);
12861290
for special_char in SPECIAL_CHARS.iter() {
12871291
let query = &format!("\\{special_char}my\\{special_char}field:a");
12881292
assert_eq!(

src/query/query_parser/query_parser.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1790,6 +1790,15 @@ mod test {
17901790
}
17911791
}
17921792

1793+
#[test]
1794+
fn test_space_before_value() {
1795+
test_parse_query_to_logical_ast_helper(
1796+
"title: a",
1797+
r#"Term(field=0, type=Str, "a")"#,
1798+
false,
1799+
);
1800+
}
1801+
17931802
#[test]
17941803
fn test_escaped_field() {
17951804
let mut schema_builder = Schema::builder();

0 commit comments

Comments
 (0)