From 75d48e65eaac9e97283bb14fdec54a143d9997f1 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Wed, 1 Aug 2018 14:12:49 -0400 Subject: Bind Integers to int for cx_Oracle For cx_Oracle, Integer datatypes will now be bound to "int", per advice from the cx_Oracle developers. Previously, using cx_Oracle.NUMBER caused a loss in precision within the cx_Oracle 6.x series. Change-Id: I4c6b2cca490aff5b98b7ceff3414715202881c89 Fixes: #4309 --- lib/sqlalchemy/testing/suite/test_types.py | 36 +++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) (limited to 'lib/sqlalchemy/testing') diff --git a/lib/sqlalchemy/testing/suite/test_types.py b/lib/sqlalchemy/testing/suite/test_types.py index 4cdf14dc9..04e0b3b23 100644 --- a/lib/sqlalchemy/testing/suite/test_types.py +++ b/lib/sqlalchemy/testing/suite/test_types.py @@ -5,7 +5,8 @@ from ..assertions import eq_ from ..config import requirements from sqlalchemy import Integer, Unicode, UnicodeText, select, TIMESTAMP from sqlalchemy import Date, DateTime, Time, MetaData, String, \ - Text, Numeric, Float, literal, Boolean, cast, null, JSON, and_, type_coerce + Text, Numeric, Float, literal, Boolean, cast, null, JSON, and_, \ + type_coerce, BigInteger from ..schema import Table, Column from ... import testing import decimal @@ -337,6 +338,39 @@ class IntegerTest(_LiteralRoundTripFixture, fixtures.TestBase): def test_literal(self): self._literal_round_trip(Integer, [5], [5]) + def test_huge_int(self): + self._round_trip(BigInteger, 1376537018368127) + + @testing.provide_metadata + def _round_trip(self, datatype, data): + metadata = self.metadata + int_table = Table( + 'integer_table', metadata, + Column('id', Integer, primary_key=True, + test_needs_autoincrement=True), + Column('integer_data', datatype), + ) + + metadata.create_all(config.db) + + config.db.execute( + int_table.insert(), + {'integer_data': data} + ) + + row = config.db.execute( + select([ + int_table.c.integer_data, + ]) + ).first() + + eq_(row, (data, )) + + if util.py3k: + assert isinstance(row[0], int) + else: + assert isinstance(row[0], (long, int)) + class NumericTest(_LiteralRoundTripFixture, fixtures.TestBase): __backend__ = True -- cgit v1.2.1