[Sqlalchemy-tickets] Issue #4309: Query with a big number returns wrong result using cx_Oracle (zzz
Brought to you by:
zzzeek
From: EmilijusS <iss...@bi...> - 2018-08-01 14:40:00
|
New issue 4309: Query with a big number returns wrong result using cx_Oracle https://bitbucket.org/zzzeek/sqlalchemy/issues/4309/query-with-a-big-number-returns-wrong EmilijusS: ## Environment :## 1. Python 2.7.11 1. cx_Oracle 5.2.1 works fine, cx_Oracle 6.4.1 (and other 6.x.x versions) don't 1. Oracle client version 12.1.0.2.0 1. Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production 1. Linux CentOS 6.10 1. GCC 6.3.0 1. SQLAlchemy 1.2.10 ## Example code:## ``` #!python from sqlalchemy import create_engine, Column, Integer from sqlalchemy.orm import sessionmaker from sqlalchemy.ext.declarative import declarative_base Base = declarative_base() def main(): engine = create_engine("oracle://CONNECTIONSTRING") Base.metadata.create_all( engine ) ss = sessionmaker( bind=engine ) s = ss() engine.execute("INSERT INTO Test (number) VALUES (1376537018368127);") engine.execute("INSERT INTO Test (number) VALUES (1376537018368130);") s.close() s = ss() result = s.query(Test).filter(Test.number == 1376537018368127).first() print result.number s.close() class Test( Base ): __tablename__ = 'Test' number = Column( Integer, primary_key=True ) main() ``` With cx_Oracle 5.2.1 prints: ``` #!python 1376537018368127 ``` With cx_Oracle 6.4.1 prints: ``` #!python 1376537018368130 ``` ##Additional information:## Sorry if the code doesn't work, I don't really have a way to test it as I can only access this one production Oracle database in which the bug was spotted. [Probably related post in stackoverflow ](https://stackoverflow.com/questions/48406354/sqlalchemy-large-number-truncation-rounding-issue-in-oracle) |