Skip to content

Fix quotation marks of tag values and escaping of field values #68

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
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
15 changes: 10 additions & 5 deletions influxdb/src/query/line_proto_term.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ impl LineProtoTerm<'_> {
Float(v) => v.to_string(),
SignedInteger(v) => format!("{}i", v),
UnsignedInteger(v) => format!("{}i", v),
Text(v) => format!(r#""{}""#, Self::escape_any(v, &*SLASHES)),
Text(v) => format!(r#""{}""#, Self::escape_any(v, &*QUOTES_SLASHES)),
}
}

Expand All @@ -59,9 +59,9 @@ impl LineProtoTerm<'_> {
}
}
.to_string(),
Float(v) => format!(r#""{}""#, v.to_string()),
SignedInteger(v) => format!(r#""{}""#, v),
UnsignedInteger(v) => format!(r#""{}""#, v),
Float(v) => format!(r#"{}"#, v),
SignedInteger(v) => format!(r#"{}"#, v),
UnsignedInteger(v) => format!(r#"{}"#, v),
Text(v) => Self::escape_any(v, &*SLASHES),
}
}
Expand All @@ -78,6 +78,11 @@ mod test {

#[test]
fn test() {
assert_eq!(TagValue(&Type::Boolean(true)).escape(), r#"true"#);
assert_eq!(TagValue(&Type::Float(1.8324f64)).escape(), r#"1.8324"#);
assert_eq!(TagValue(&Type::SignedInteger(-1i64)).escape(), r#"-1"#);
assert_eq!(TagValue(&Type::UnsignedInteger(1u64)).escape(), r#"1"#);

assert_eq!(
TagValue(&Type::Text("this is my special string".into())).escape(),
r#"this\ is\ my\ special\ string"#
Expand Down Expand Up @@ -112,7 +117,7 @@ mod test {
assert_eq!(FieldValue(&Type::Text("\"".into())).escape(), r#""\"""#);
assert_eq!(
FieldValue(&Type::Text(r#"locat"\ ,=ion"#.into())).escape(),
r#""locat\"\\\ \,\=ion""#
r#""locat\"\\ ,=ion""#
);
}

Expand Down
2 changes: 1 addition & 1 deletion influxdb/tests/derive_integration_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ fn test_build_query() {
.unwrap();
assert_eq!(
query.get(),
"weather_reading,wind_strength=\"5\" humidity=30i 3600000000000"
"weather_reading,wind_strength=5 humidity=30i 3600000000000"
);
}

Expand Down