diff --git a/doc/build/changelog/changelog_07.rst b/doc/build/changelog/changelog_07.rst index 578244625..5132bd961 100644 --- a/doc/build/changelog/changelog_07.rst +++ b/doc/build/changelog/changelog_07.rst @@ -27,6 +27,15 @@ to the MSSQL dialect's "schema rendering" logic's failure to take .key into account. + .. change:: + :tags: oracle, bug + :tickets: 2620 + + The Oracle LONG type, while an unbounded text type, does not appear + to use the cx_Oracle.LOB type when result rows are returned, + so the dialect has been repaired to exclude LONG from + having cx_Oracle.LOB filtering applied. + .. change:: :tags: oracle, bug :tickets: 2611 diff --git a/lib/sqlalchemy/dialects/oracle/cx_oracle.py b/lib/sqlalchemy/dialects/oracle/cx_oracle.py index 37c9562f2..ba505bcfd 100644 --- a/lib/sqlalchemy/dialects/oracle/cx_oracle.py +++ b/lib/sqlalchemy/dialects/oracle/cx_oracle.py @@ -283,6 +283,13 @@ class _OracleText(_LOBMixin, sqltypes.Text): def get_dbapi_type(self, dbapi): return dbapi.CLOB +class _OracleLong(oracle.LONG): + # a raw LONG is a text type, but does *not* + # get the LobMixin with cx_oracle. + + def get_dbapi_type(self, dbapi): + return dbapi.LONG_STRING + class _OracleString(_NativeUnicodeMixin, sqltypes.String): pass @@ -502,6 +509,11 @@ class OracleDialect_cx_oracle(OracleDialect): sqltypes.String : _OracleString, sqltypes.UnicodeText : _OracleUnicodeText, sqltypes.CHAR : _OracleChar, + + # a raw LONG is a text type, but does *not* + # get the LobMixin with cx_oracle. + oracle.LONG: _OracleLong, + sqltypes.Integer : _OracleInteger, # this is only needed for OUT parameters. # it would be nice if we could not use it otherwise. oracle.RAW: _OracleRaw, diff --git a/test/dialect/test_oracle.py b/test/dialect/test_oracle.py index 1e8aa028a..c6f8f32cb 100644 --- a/test/dialect/test_oracle.py +++ b/test/dialect/test_oracle.py @@ -1189,6 +1189,21 @@ class TypesTest(fixtures.TestBase): finally: t1.drop() + @testing.provide_metadata + def test_long_type(self): + metadata = self.metadata + + t = Table('t', metadata, + Column('data', oracle.LONG) + ) + metadata.create_all(testing.db) + testing.db.execute(t.insert(), data='xyz') + eq_( + testing.db.scalar(select([t.c.data])), + "xyz" + ) + + def test_longstring(self): metadata = MetaData(testing.db)