]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
The Oracle LONG type, while an unbounded text type, does not appear
authorMike Bayer <mike_mp@zzzcomputing.com>
Fri, 7 Dec 2012 00:32:58 +0000 (19:32 -0500)
committerMike Bayer <mike_mp@zzzcomputing.com>
Fri, 7 Dec 2012 00:32:58 +0000 (19:32 -0500)
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.
[ticket:2620]

doc/build/changelog/changelog_07.rst
lib/sqlalchemy/dialects/oracle/cx_oracle.py
test/dialect/test_oracle.py

index 5782446252b0d91b24bc4c058a940331524260d3..5132bd961321bb2cf4571c61a081da7334288677 100644 (file)
       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
index 37c9562f2620d7fd83a96d487b421c9cc3074837..ba505bcfdad4453481c21ad199a381549c2991e4 100644 (file)
@@ -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,
index 1e8aa028a34fab994ff04312b0b382bdfabab098..c6f8f32cb965a636043bd6033dabd048ac887bf2 100644 (file)
@@ -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)