Skip to content

Commit 55d497f

Browse files
Fix quotation marks of tag values and escaping of field values (#68)
* remove quotation marks from all tag values * only escape quotation marks
1 parent f40c2ec commit 55d497f

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

influxdb/src/query/line_proto_term.rs

+10-5
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ impl LineProtoTerm<'_> {
4444
Float(v) => v.to_string(),
4545
SignedInteger(v) => format!("{}i", v),
4646
UnsignedInteger(v) => format!("{}i", v),
47-
Text(v) => format!(r#""{}""#, Self::escape_any(v, &*SLASHES)),
47+
Text(v) => format!(r#""{}""#, Self::escape_any(v, &*QUOTES_SLASHES)),
4848
}
4949
}
5050

@@ -59,9 +59,9 @@ impl LineProtoTerm<'_> {
5959
}
6060
}
6161
.to_string(),
62-
Float(v) => format!(r#""{}""#, v.to_string()),
63-
SignedInteger(v) => format!(r#""{}""#, v),
64-
UnsignedInteger(v) => format!(r#""{}""#, v),
62+
Float(v) => format!(r#"{}"#, v),
63+
SignedInteger(v) => format!(r#"{}"#, v),
64+
UnsignedInteger(v) => format!(r#"{}"#, v),
6565
Text(v) => Self::escape_any(v, &*SLASHES),
6666
}
6767
}
@@ -78,6 +78,11 @@ mod test {
7878

7979
#[test]
8080
fn test() {
81+
assert_eq!(TagValue(&Type::Boolean(true)).escape(), r#"true"#);
82+
assert_eq!(TagValue(&Type::Float(1.8324f64)).escape(), r#"1.8324"#);
83+
assert_eq!(TagValue(&Type::SignedInteger(-1i64)).escape(), r#"-1"#);
84+
assert_eq!(TagValue(&Type::UnsignedInteger(1u64)).escape(), r#"1"#);
85+
8186
assert_eq!(
8287
TagValue(&Type::Text("this is my special string".into())).escape(),
8388
r#"this\ is\ my\ special\ string"#
@@ -112,7 +117,7 @@ mod test {
112117
assert_eq!(FieldValue(&Type::Text("\"".into())).escape(), r#""\"""#);
113118
assert_eq!(
114119
FieldValue(&Type::Text(r#"locat"\ ,=ion"#.into())).escape(),
115-
r#""locat\"\\\ \,\=ion""#
120+
r#""locat\"\\ ,=ion""#
116121
);
117122
}
118123

influxdb/tests/derive_integration_tests.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ fn test_build_query() {
3535
.unwrap();
3636
assert_eq!(
3737
query.get(),
38-
"weather_reading,wind_strength=\"5\" humidity=30i 3600000000000"
38+
"weather_reading,wind_strength=5 humidity=30i 3600000000000"
3939
);
4040
}
4141

0 commit comments

Comments
 (0)