Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cx_Oracle inserts wrong value into NUMBER column for small absolute values #366

Closed
rgoodman-qontigo opened this issue Oct 29, 2019 · 3 comments

Comments

@rgoodman-qontigo
Copy link

Environment:

Ubuntu 16.04, Python 3.5, 64-bit, Oracle instant client version 12.2, Oracle server version 10.2
cx_Oracle version 7.1.2

When inserting rows into a table with a NUMBER column, the value that is actually put into the database is incorrect when the the absolute value of the input is less than 1E-07.

Here is the output from the code which can be found at https://gist.github.com/RGoodmanAxioma/c91de53c441f3b96d86f0ac500eab93b

{'value_arg': 7.022527025261419e-08, 'factor2_arg': 859, 'rms_arg': 109, 'factor1_arg': 822, 'date_arg': 'datetime.date(2017, 8, 16)'} [(7.022527025261419,)]
{'value_arg': 5.879045268100333e-08, 'factor2_arg': 206, 'rms_arg': 109, 'factor1_arg': 267, 'date_arg': 'datetime.date(2017, 8, 16)'} [(5.879045268100333,)]
{'value_arg': -3.306667801858156e-08, 'factor2_arg': 3, 'rms_arg': 109, 'factor1_arg': 382, 'date_arg': 'datetime.date(2017, 8, 16)'} [(-3.306667801858156,)]
{'value_arg': 9.664270079412593e-08, 'factor2_arg': 340, 'rms_arg': 109, 'factor1_arg': 340, 'date_arg': 'datetime.date(2017, 8, 16)'} [(9.664270079412592,)]
{'value_arg': 2.4202030223245456e-08, 'factor2_arg': 6, 'rms_arg': 109, 'factor1_arg': 381, 'date_arg': 'datetime.date(2017, 8, 16)'} [(2.4202030223245456,)]
{'value_arg': 5.7229195197041604e-08, 'factor2_arg': 816, 'rms_arg': 109, 'factor1_arg': 381, 'date_arg': 'datetime.date(2017, 8, 16)'} [(5.722919519704161,)]

The value_arg in the dictionary is what is supposed to be inserted into the database. The last part of each line is what is read from the database. If any of the values are changed to E-07 instead, then no differences are printed. The records in the code are extracted from a much longer list of records, but these are the only records for which the problem occurred, and they are the only records which had values whose absolute value was less than 1E-07.

@cjbj
Copy link
Member

cjbj commented Oct 29, 2019

Please try with the latest cx_Oracle.

@anthony-tuininga
Copy link
Member

Specifically, issue #300 might be relevant, which is fixed in cx_Oracle 7.2.

@rgoodman-qontigo
Copy link
Author

Duplicate of #300

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants