diff --git a/lib/influxdb2/client/point.rb b/lib/influxdb2/client/point.rb index 8d1d5bbd..fa87179d 100644 --- a/lib/influxdb2/client/point.rb +++ b/lib/influxdb2/client/point.rb @@ -45,7 +45,7 @@ def initialize(name:, tags: nil, fields: nil, time: nil, precision: DEFAULT_WRIT @time = time @precision = precision end - attr_writer :precision + attr_reader :precision # Create DataPoint instance from specified data. # diff --git a/lib/influxdb2/client/write_api.rb b/lib/influxdb2/client/write_api.rb index 2cf38726..7c3e32a5 100644 --- a/lib/influxdb2/client/write_api.rb +++ b/lib/influxdb2/client/write_api.rb @@ -158,7 +158,7 @@ def initialize(key, data) # Key for batch item class BatchItemKey - def initialize(bucket, org, precision = DEFAULT_WRITE_PRECISION) + def initialize(bucket, org, precision: DEFAULT_WRITE_PRECISION) @bucket = bucket @org = org @precision = precision @@ -197,7 +197,8 @@ def _generate_payload(data, precision: nil, bucket: nil, org: nil) if data.nil? nil elsif data.is_a?(Point) - _generate_payload(data.to_line_protocol, bucket: bucket, org: org, precision: data.precision) + _generate_payload(data.to_line_protocol, bucket: bucket, org: org, precision: data.precision || + DEFAULT_WRITE_PRECISION) elsif data.is_a?(String) if data.empty? nil