Skip to content
This repository was archived by the owner on Oct 29, 2024. It is now read-only.

fix for lost precision on float field values #430

Merged
merged 2 commits into from
Apr 10, 2017

Conversation

isilien
Copy link
Contributor

@isilien isilien commented Mar 22, 2017

use repr() instead of str() when casting floats into strings so that float(repr(my_float)) == my_float can be guaranteed, which is not the case when using str()

@@ -119,3 +119,19 @@ def test_quote_literal(self):
line_protocol.quote_literal(r"""\foo ' bar " Örf"""),
r"""'\\foo \' bar " Örf'"""
)

def test_float_with_long_decimal_fraction(self):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To conform to pep257 this public method should have a docstring, see #415

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

@aviau
Copy link
Collaborator

aviau commented Apr 10, 2017

thanks to you both!

@aviau aviau merged commit 8e02ea8 into influxdata:master Apr 10, 2017
@chripede
Copy link

Any chance this could cause Decimal values to fail?

InfluxDBClientError: 400: {"error":"unable to parse 'sale,host=app,payment_type=downgrade value=Decimal('29.95') 1492496475567468032': invalid boolean"}

I think the problem might be that float() will return a float on a Decimal, but repr will actually return "Decimal('29.95')"

@ghost
Copy link

ghost commented Jul 27, 2017

I guess I do hae something like this here ::

influxdb.exceptions.InfluxDBClientError: 400: {"error":"partial write: unable to parse 'totalgain value=Decimal('2695.30')': invalid boolean dropped=0"}

Is there a workaround?

@ghost ghost mentioned this pull request Jul 27, 2017
@ghost ghost mentioned this pull request Aug 11, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy