fix: Allow multiple whitespace characters between line protocol elements
parent
9b9ddc8508
commit
aff4906a72
|
@ -352,8 +352,8 @@ fn parse_lines(mut i: &str) -> impl Iterator<Item = Result<ParsedLine<'_>>> {
|
|||
}
|
||||
|
||||
fn parse_line(i: &str) -> IResult<&str, ParsedLine<'_>> {
|
||||
let field_set = preceded(tag(" "), field_set);
|
||||
let timestamp = preceded(tag(" "), timestamp);
|
||||
let field_set = preceded(whitespace, field_set);
|
||||
let timestamp = preceded(whitespace, timestamp);
|
||||
|
||||
let line = tuple((series, field_set, opt(timestamp)));
|
||||
|
||||
|
@ -459,6 +459,10 @@ fn line_whitespace(mut i: &str) -> IResult<&str, ()> {
|
|||
}
|
||||
}
|
||||
|
||||
fn whitespace(i: &str) -> IResult<&str, &str> {
|
||||
take_while1(|c| c == ' ')(i)
|
||||
}
|
||||
|
||||
/// While not all of these escape characters are required to be
|
||||
/// escaped, we support the client escaping them proactively to
|
||||
/// provide a common experience.
|
||||
|
@ -788,6 +792,18 @@ foo value2=2i 123"#;
|
|||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse_multiple_whitespace_between_elements_is_allowed() -> Result {
|
||||
let input = " measurement a=1i 123 ";
|
||||
let vals = parse(input)?;
|
||||
|
||||
assert_eq!(vals[0].series(), "measurement\ta");
|
||||
assert_eq!(vals[0].time(), 123);
|
||||
assert_eq!(vals[0].i64_value().unwrap(), 1);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
macro_rules! assert_fully_parsed {
|
||||
($parse_result:expr, $output:expr $(,)?) => {{
|
||||
let (remaining, parsed) = $parse_result?;
|
||||
|
|
Loading…
Reference in New Issue