]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
auto_convert_lobs=False honored by OracleBinary, OracleText types
authorMike Bayer <mike_mp@zzzcomputing.com>
Fri, 24 Oct 2008 17:09:58 +0000 (17:09 +0000)
committerMike Bayer <mike_mp@zzzcomputing.com>
Fri, 24 Oct 2008 17:09:58 +0000 (17:09 +0000)
[ticket:1178]

CHANGES
lib/sqlalchemy/databases/oracle.py
test/dialect/oracle.py

diff --git a/CHANGES b/CHANGES
index 41fa821a02941fcfd9d5b2bec840f29d43d68cca..e88175a7bcc12ba04978f51b3efae8898e4894bb 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,5 +1,6 @@
 -*- coding: utf-8; fill-column: 68 -*-
 
+
 =======
 CHANGES
 =======
@@ -60,6 +61,11 @@ CHANGES
     - Wrote a docstring for Oracle dialect.  Apparently that
       Ohloh "few source code comments" label is starting to sting
       :).
+
+    - Setting the auto_convert_lobs to False on create_engine()
+      will also instruct the OracleBinary type to return the
+      cx_oracle LOB object unchanged.
+
 0.5.0rc2
 ========
 - orm
index 7be33d269f2507f7983ffd6920caefe2a92b5c76..ffd52c38c6f2971fbeb36f45ed27bba3adc5e993 100644 (file)
@@ -81,10 +81,7 @@ The conversion of LOB objects by this dialect is unique in SQLAlchemy in that it
 for all statement executions, even plain string-based statements for which SQLA has no awareness
 of result typing.  This is so that calls like fetchmany() and fetchall() can work in all cases
 without raising cursor errors.  The conversion of LOB in all cases, as well as the "prefetch"
-of LOB objects, can be disabled using auto_convert_lobs=False.  However, OracleBinary type 
-objects will still issue the conversion of LOBs upon access - use a string-based or otherwise
-untyped select() construct, or a custom Binary type, to retrieve LOB objects directly in this case.
-A future release may include a flag on OracleBinary to further disable LOB conversion at that level.
+of LOB objects, can be disabled using auto_convert_lobs=False.  
 
 LIMIT/OFFSET Support
 
@@ -207,6 +204,8 @@ class OracleText(sqltypes.Text):
 
     def result_processor(self, dialect):
         super_process = super(OracleText, self).result_processor(dialect)
+        if not dialect.auto_convert_lobs:
+            return super_process
         lob = dialect.dbapi.LOB
         def process(value):
             if isinstance(value, lob):
@@ -237,6 +236,8 @@ class OracleBinary(sqltypes.Binary):
         return None
 
     def result_processor(self, dialect):
+        if not dialect.auto_convert_lobs:
+            return None
         lob = dialect.dbapi.LOB
         def process(value):
             if isinstance(value, lob):
index 10cc94193d7b1f19a8d5c61b69a58ea136eed2a0..611e4bc50961a70807342864368a5ddc6fcc4a63 100644 (file)
@@ -3,6 +3,7 @@ from sqlalchemy import *
 from sqlalchemy.sql import table, column
 from sqlalchemy.databases import oracle
 from testlib import *
+from testlib.testing import eq_
 from testlib.engines import testing_engine
 import os
 
@@ -311,6 +312,19 @@ class TypesTest(TestBase, AssertsCompiledSQL):
         finally:
             testing.db.execute("DROP TABLE Z_TEST")
 
+    def test_raw_lobs(self):
+        engine = testing_engine(options=dict(auto_convert_lobs=False))
+        metadata = MetaData()
+        t = Table("z_test", metadata, Column('id', Integer, primary_key=True), 
+                 Column('data', Text), Column('bindata', Binary))
+        t.create(engine)
+        try:
+            engine.execute(t.insert(), id=1, data='this is text', bindata='this is binary')
+            row = engine.execute(t.select()).fetchone()
+            eq_(row['data'].read(), 'this is text')
+            eq_(row['bindata'].read(), 'this is binary')
+        finally:
+            t.drop(engine)
 class BufferedColumnTest(TestBase, AssertsCompiledSQL):
     __only_on__ = 'oracle'