From: Mike Bayer Date: Fri, 7 Dec 2012 00:30:49 +0000 (-0500) Subject: The Oracle LONG type, while an unbounded text type, does not appear X-Git-Tag: rel_0_8_0b2~17^2~2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=9d817406e2da0bda91c1e9a1411165f229e3d5c2;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git 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. Also in 0.7.10. [ticket:2620] --- diff --git a/doc/build/changelog/changelog_07.rst b/doc/build/changelog/changelog_07.rst index 1bb483280f..092e8af40f 100644 --- a/doc/build/changelog/changelog_07.rst +++ b/doc/build/changelog/changelog_07.rst @@ -8,6 +8,15 @@ :version: 0.7.10 :released: + .. 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/doc/build/changelog/changelog_08.rst b/doc/build/changelog/changelog_08.rst index dad8df6ce0..79597366c9 100644 --- a/doc/build/changelog/changelog_08.rst +++ b/doc/build/changelog/changelog_08.rst @@ -6,6 +6,15 @@ .. changelog:: :version: 0.8.0b2 + .. 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. Also in 0.7.10. + .. 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 8b60d9af81..c5d9e8a897 100644 --- a/lib/sqlalchemy/dialects/oracle/cx_oracle.py +++ b/lib/sqlalchemy/dialects/oracle/cx_oracle.py @@ -303,6 +303,13 @@ class _OracleText(_LOBMixin, sqltypes.Text): 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 @@ -532,6 +539,10 @@ class OracleDialect_cx_oracle(OracleDialect): 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, + # this is only needed for OUT parameters. # it would be nice if we could not use it otherwise. sqltypes.Integer: _OracleInteger, diff --git a/test/dialect/test_oracle.py b/test/dialect/test_oracle.py index 7604bf9287..80ab91a919 100644 --- a/test/dialect/test_oracle.py +++ b/test/dialect/test_oracle.py @@ -1315,6 +1315,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)