File tree Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -75,12 +75,22 @@ def quote_literal(value):
75
75
)
76
76
77
77
78
+ def _is_float (value ):
79
+ try :
80
+ float (value )
81
+ except ValueError :
82
+ return False
83
+ return True
84
+
85
+
78
86
def _escape_value (value ):
79
87
value = _get_unicode (value )
80
88
if isinstance (value , text_type ) and value != '' :
81
89
return quote_ident (value )
82
90
elif isinstance (value , integer_types ) and not isinstance (value , bool ):
83
91
return str (value ) + 'i'
92
+ elif _is_float (value ):
93
+ return repr (value )
84
94
else :
85
95
return str (value )
86
96
Original file line number Diff line number Diff line change @@ -119,3 +119,19 @@ def test_quote_literal(self):
119
119
line_protocol .quote_literal (r"""\foo ' bar " Örf""" ),
120
120
r"""'\\foo \' bar " Örf'"""
121
121
)
122
+
123
+ def test_float_with_long_decimal_fraction (self ):
124
+ data = {
125
+ "points" : [
126
+ {
127
+ "measurement" : "test" ,
128
+ "fields" : {
129
+ "float_val" : 1.0000000000000009 ,
130
+ }
131
+ }
132
+ ]
133
+ }
134
+ self .assertEqual (
135
+ line_protocol .make_lines (data ),
136
+ 'test float_val=1.0000000000000009\n '
137
+ )
You can’t perform that action at this time.
0 commit comments