Skip to content

Commit 39f696b

Browse files
committed
chore: add detail information for not supported type of Point.field
1 parent e26e7b0 commit 39f696b

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

influxdb_client/client/write/point.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ def _append_fields(fields):
165165
elif isinstance(value, str):
166166
_return.append(f'{_escape_key(field)}="{_escape_string(value)}"')
167167
else:
168-
raise ValueError()
168+
raise ValueError(f'Type: "{type(value)}" of field: "{field}" is not supported.')
169169

170170
return f"{','.join(_return)}"
171171

tests/test_point.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,16 @@ def test_points_from_different_timezones(self):
369369
point_hk = Point.measurement("h2o").field("val", 1).time(time_in_hk)
370370
self.assertEqual(point_utc.to_line_protocol(), point_hk.to_line_protocol())
371371

372+
def test_unsupported_field_type(self):
373+
with self.assertRaises(ValueError) as ve:
374+
Point.measurement("h2o") \
375+
.tag("location", "europe") \
376+
.field("level", UTC) \
377+
.to_line_protocol()
378+
exception = ve.exception
379+
380+
self.assertEqual('Type: "<class \'pytz.UTC\'>" of field: "level" is not supported.', f'{exception}')
381+
372382

373383
if __name__ == '__main__':
374384
unittest.main()

0 commit comments

Comments
 (0)