@@ -36,7 +36,7 @@ fn field_name(inp: &str) -> IResult<&str, String> {
36
36
alt ( ( first_char, escape_sequence ( ) ) ) ,
37
37
many0 ( alt ( ( simple_char, escape_sequence ( ) , char ( '\\' ) ) ) ) ,
38
38
) ) ,
39
- char ( ':' ) ,
39
+ tuple ( ( multispace0 , char ( ':' ) , multispace0 ) ) ,
40
40
) ,
41
41
|( first_char, next) | once ( first_char) . chain ( next) . collect ( ) ,
42
42
) ( inp)
@@ -1283,6 +1283,10 @@ mod test {
1283
1283
super :: field_name( "~my~field:a" ) ,
1284
1284
Ok ( ( "a" , "~my~field" . to_string( ) ) )
1285
1285
) ;
1286
+ assert_eq ! (
1287
+ super :: field_name( ".my.field.name : a" ) ,
1288
+ Ok ( ( "a" , ".my.field.name" . to_string( ) ) )
1289
+ ) ;
1286
1290
for special_char in SPECIAL_CHARS . iter ( ) {
1287
1291
let query = & format ! ( "\\ {special_char}my\\ {special_char}field:a" ) ;
1288
1292
assert_eq ! (
@@ -1689,4 +1693,15 @@ mod test {
1689
1693
fn test_invalid_field ( ) {
1690
1694
test_is_parse_err ( r#"!bc:def"# , "!bc:def" ) ;
1691
1695
}
1696
+
1697
+ #[ test]
1698
+ fn test_space_before_value ( ) {
1699
+ test_parse_query_to_ast_helper ( "field : a" , r#""field":a"# ) ;
1700
+ test_parse_query_to_ast_helper ( "field: a" , r#""field":a"# ) ;
1701
+ test_parse_query_to_ast_helper ( "field :a" , r#""field":a"# ) ;
1702
+ test_parse_query_to_ast_helper (
1703
+ "field : 'happy tax payer' AND other_field : 1" ,
1704
+ r#"(+"field":'happy tax payer' +"other_field":1)"# ,
1705
+ ) ;
1706
+ }
1692
1707
}
0 commit comments