It seems that in cx_Oracle 6.x we now lose numeric precision for large integers if we bind to cx_Oracle.NUMBER, we now have to bind to cx_Oracle.NATIVE_INT, example below.
If I change SQLAlchemy to bind all integers to NATIVE_INT instead of NUMBER, what surprises are there? does this type perform very poorly or not function in all cases?
import cx_Oracle
conn = cx_Oracle.connect(
user="scott",
password="tiger",
dsn=cx_Oracle.makedsn(
"oracle1120", 1521, sid="",
)
)
cursor = conn.cursor()
try:
cursor.execute("drop table t")
except:
pass
cursor.execute("""
CREATE TABLE t (
x INTEGER
)
""")
# this works.
# cursor.setinputsizes(x=cx_Oracle.NATIVE_INT)
# this no longer does.
cursor.setinputsizes(x=cx_Oracle.NUMBER)
cursor.execute("insert into t(x) values (:x)", {"x": 1376537018368127})
cursor.execute("select x from t")
value = cursor.fetchone()[0]
# on cx_oracle 6.2 returns 1376537018368130 unless you used
# NATIVE_INT or did nothing
assert value == 1376537018368127, value