make_lines omits field values with empty strings #655
Description
When writing a point where one or more field values are empty strings (""
), influxdb-python will omit them in the line protocol representation. If there are no non-empty fields, this will omit all fields, resulting in an invalid line protocol format and an error.
For example, the following is allowed on the influx command line interface:
> INSERT m0 value=""
> SELECT * FROM m0
name: m0
time value
---- -----
1540946138927548393
However, the equivalent in python results in an InfluxDBClientError:
def test_client_nonempty_field_string(client):
point = {
"measurement": "m0",
"fields": { "value": "foo" },
}
# succeeds
client.write_points([point])
def test_client_empty_field_string(client):
point = {
"measurement": "m0",
"fields": { "value": "" },
}
# raises InfluxDBClientError: 400: {"error":"unable to parse 'm0 ': invalid field format"}
client.write_points([point])
This appears to be related to the None
handling introduced in commit 26683a4. In that commit, a conversion from None
to ''
was introduced in _get_unicode
, and subsequently field values == ''
are filtered out in make_lines
. However, if a user explicitly passes in ''
for a field value, then those values will get caught in this check and be filtered out as well.
This affects version 5.2.0 and earlier, and was tested against influxdb 1.4.3. It may also be related to #549.