File tree 2 files changed +31
-4
lines changed 2 files changed +31
-4
lines changed Original file line number Diff line number Diff line change @@ -79,10 +79,10 @@ def make_lines(data):
79
79
tags .update (point .get ('tags' , {}))
80
80
# tags should be sorted client-side to take load off server
81
81
for tag_key in sorted (tags .keys ()):
82
- lines += "{key}={value}," . format (
83
- key = _escape_tag (tag_key ),
84
- value = _escape_tag ( tags [ tag_key ]),
85
- )
82
+ key = _escape_tag ( tag_key )
83
+ value = _escape_tag (tags [ tag_key ])
84
+ if key != '' and value != '' :
85
+ lines += "{key}={value}," . format ( key = key , value = value )
86
86
lines = lines [:- 1 ] + " " # strip the trailing comma
87
87
88
88
# add fields
Original file line number Diff line number Diff line change
1
+ # -*- coding: utf-8 -*-
2
+
3
+ import unittest
4
+ from influxdb import line_protocol
5
+
6
+
7
+ class TestLineProtocol (unittest .TestCase ):
8
+
9
+ def test_empty_tag (self ):
10
+ data = {
11
+ "tags" : {
12
+ "my_tag" : ""
13
+ },
14
+ "points" : [
15
+ {
16
+ "measurement" : "test" ,
17
+ "fields" : {
18
+ "value" : "hello!"
19
+ }
20
+ }
21
+ ]
22
+ }
23
+
24
+ self .assertEqual (
25
+ line_protocol .make_lines (data ),
26
+ 'test value="hello!"\n '
27
+ )
You can’t perform that action at this time.
0 commit comments