orca-zhang / influxdb-cpp

💜 C++ client for InfluxDB.
MIT License
163 stars 83 forks source link

InfluxDB api does not support float64 bit values #10

Closed abhijeettmr closed 5 years ago

abhijeettmr commented 5 years ago

Hi, when i tried to insert float64 or double value through InfluxDB cpp api then it return -7 as a error code but same float64value inserted through command line of InfludxDB then it inserted successfully so my conclusion is InfluxDB cpp api is not supported float64bit values. First of all '-7' status code is not understandable at first impression because their is no related document for return codes meaning so i decide to look into InfluxDB.hpp file then i found some string length issue. When i increase the length of format buffer #define FMT_BUF_LEN 25 to#define FMT_BUF_LEN 35then it works fine for me and i am able to handlefloat64 bit values upto a certain range not upto maximum range offloat64`.

Usecase: if i tried to insert float flVal = 3.14e18 then the value is not inserted into database and it returns '-7' as a error code and if insert float flVal = 3.14e17 then it inserted successfully into database. But after increasing buffer length to 35 then float flVal = 3.14e27 can be inserted into DB and bigger than that value cannot be inserted if buffer length is set to 35.

So my question is, this is correct way to handle the float64bit values or have to choose other way round. Thanks.

orca-zhang commented 5 years ago

I think that is a mistake I've made.

I'll check the documents for help, and fix it ASAP.

I haven't choose stringstream because stringstream will be influenced by locale settings by default.

Thank you for your deep feedback and detailed use case.

abhijeettmr commented 5 years ago

Hi, thanks for giving your time and looking into the issue. Sorry to interrupt you I would like just to know have you check that and adding any fix in this.

orca-zhang commented 5 years ago

I fixed it coz I'm available today. Remember to double check it again by yourself. Thanks.