Skip to content

Fix improper quoting on tag values when the value was text #64

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions influxdb/src/query/line_proto_term.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ impl LineProtoTerm<'_> {
Float(v) => format!(r#""{}""#, v.to_string()),
SignedInteger(v) => format!(r#""{}""#, v),
UnsignedInteger(v) => format!(r#""{}""#, v),
Text(v) => format!(r#""{}""#, Self::escape_any(v, &*SLASHES)),
Text(v) => Self::escape_any(v, &*SLASHES),
}
}

Expand All @@ -80,19 +80,19 @@ mod test {
fn test() {
assert_eq!(
TagValue(&Type::Text("this is my special string".into())).escape(),
r#""this\ is\ my\ special\ string""#
r#"this\ is\ my\ special\ string"#
);
assert_eq!(
TagValue(&Type::Text("a tag w=i th == tons of escapes".into())).escape(),
r#""a\ tag\ w\=i\ th\ \=\=\ tons\ of\ escapes""#
r#"a\ tag\ w\=i\ th\ \=\=\ tons\ of\ escapes"#
);
assert_eq!(
TagValue(&Type::Text("no_escapes".into())).escape(),
r#""no_escapes""#
r#"no_escapes"#
);
assert_eq!(
TagValue(&Type::Text("some,commas,here".into())).escape(),
r#""some\,commas\,here""#
r#"some\,commas\,here"#
);

assert_eq!(Measurement(r#"wea", ther"#).escape(), r#"wea"\,\ ther"#);
Expand Down Expand Up @@ -120,6 +120,6 @@ mod test {
fn test_empty_tag_value() {
// InfluxDB doesn't support empty tag values. But that's a job
// of a calling site to validate an entire write request.
assert_eq!(TagValue(&Type::Text("".into())).escape(), r#""""#);
assert_eq!(TagValue(&Type::Text("".into())).escape(), r#""#);
}
}
6 changes: 3 additions & 3 deletions influxdb/src/query/write_query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ mod tests {
assert!(query.is_ok(), "Query was empty");
assert_eq!(
query.unwrap(),
r#"weather,location="us-midwest",season="summer" temperature=82i 11"#
r#"weather,location=us-midwest,season=summer temperature=82i 11"#
);
}

Expand All @@ -307,15 +307,15 @@ mod tests {
.add_field("\"temp=era,t ure\"", r#"too"\\hot"#)
.add_field("float", 82.0)
.add_tag("location", "us-midwest")
.add_tag("loc, =\"ation", r#"us, "mid=west""#)
.add_tag("loc, =\"ation", r#"us, "mid=west"#)
.build();

assert!(query.is_ok(), "Query was empty");
let query_res = query.unwrap().get();
#[allow(clippy::print_literal)]
assert_eq!(
query_res,
r#"wea\,\ ther=,location="us-midwest",loc\,\ \="ation="us\,\ \"mid\=west\"" temperature=82i,"temp\=era\,t\ ure"="too\"\\\\hot",float=82 11"#
r#"wea\,\ ther=,location=us-midwest,loc\,\ \="ation=us\,\ \"mid\=west temperature=82i,"temp\=era\,t\ ure"="too\"\\\\hot",float=82 11"#
);
}
}