Skip to content

Commit f40c2ec

Browse files
authored
Fix improper quoting on tag values when the value was text (#64)
* Fix improper quoting on tag values when the value was text * Fix clippy warnings and tests
1 parent 9c2f37c commit f40c2ec

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

influxdb/src/query/line_proto_term.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ impl LineProtoTerm<'_> {
6262
Float(v) => format!(r#""{}""#, v.to_string()),
6363
SignedInteger(v) => format!(r#""{}""#, v),
6464
UnsignedInteger(v) => format!(r#""{}""#, v),
65-
Text(v) => format!(r#""{}""#, Self::escape_any(v, &*SLASHES)),
65+
Text(v) => Self::escape_any(v, &*SLASHES),
6666
}
6767
}
6868

@@ -80,19 +80,19 @@ mod test {
8080
fn test() {
8181
assert_eq!(
8282
TagValue(&Type::Text("this is my special string".into())).escape(),
83-
r#""this\ is\ my\ special\ string""#
83+
r#"this\ is\ my\ special\ string"#
8484
);
8585
assert_eq!(
8686
TagValue(&Type::Text("a tag w=i th == tons of escapes".into())).escape(),
87-
r#""a\ tag\ w\=i\ th\ \=\=\ tons\ of\ escapes""#
87+
r#"a\ tag\ w\=i\ th\ \=\=\ tons\ of\ escapes"#
8888
);
8989
assert_eq!(
9090
TagValue(&Type::Text("no_escapes".into())).escape(),
91-
r#""no_escapes""#
91+
r#"no_escapes"#
9292
);
9393
assert_eq!(
9494
TagValue(&Type::Text("some,commas,here".into())).escape(),
95-
r#""some\,commas\,here""#
95+
r#"some\,commas\,here"#
9696
);
9797

9898
assert_eq!(Measurement(r#"wea", ther"#).escape(), r#"wea"\,\ ther"#);
@@ -120,6 +120,6 @@ mod test {
120120
fn test_empty_tag_value() {
121121
// InfluxDB doesn't support empty tag values. But that's a job
122122
// of a calling site to validate an entire write request.
123-
assert_eq!(TagValue(&Type::Text("".into())).escape(), r#""""#);
123+
assert_eq!(TagValue(&Type::Text("".into())).escape(), r#""#);
124124
}
125125
}

influxdb/src/query/write_query.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ mod tests {
282282
assert!(query.is_ok(), "Query was empty");
283283
assert_eq!(
284284
query.unwrap(),
285-
r#"weather,location="us-midwest",season="summer" temperature=82i 11"#
285+
r#"weather,location=us-midwest,season=summer temperature=82i 11"#
286286
);
287287
}
288288

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

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

0 commit comments

Comments
 (0)