Skip to content
This repository was archived by the owner on Oct 29, 2024. It is now read-only.

Fix newline in tag value cause partial commit #716

Merged
merged 1 commit into from
Jul 11, 2019
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
2 changes: 2 additions & 0 deletions influxdb/line_protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ def _escape_tag(tag):
",", "\\,"
).replace(
"=", "\\="
).replace(
"\n", "\\n"
)


Expand Down
21 changes: 21 additions & 0 deletions influxdb/tests/test_line_protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,27 @@ def test_make_lines_unicode(self):
'test,unicode_tag=\'Привет!\' unicode_val="Привет!"\n'
)

def test_tag_value_newline(self):
"""Test make lines with tag value contains newline."""
data = {
"tags": {
"t1": "line1\nline2"
},
"points": [
{
"measurement": "test",
"fields": {
"val": "hello"
}
}
]
}

self.assertEqual(
line_protocol.make_lines(data),
'test,t1=line1\\nline2 val="hello"\n'
)

def test_quote_ident(self):
"""Test quote indentation in TestLineProtocol object."""
self.assertEqual(
Expand Down