summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2007-02-17 01:18:54 +0000
committerMike Bayer <mike_mp@zzzcomputing.com>2007-02-17 01:18:54 +0000
commit5f83c55fc7710ad495e64268627949ca91a66c72 (patch)
tree4f4f4f3b10f856051e481324ca6415dfd7e7f4cf
parent67f020f69cbca55150c2d793ba3f9fcb95749838 (diff)
downloadsqlalchemy-5f83c55fc7710ad495e64268627949ca91a66c72.tar.gz
- fixed oracle list of binary types to check for their presence in the module (such as BFILE not in all versions of cx_Oracle)
- removed oracle-handicap from binary unit test to test [ticket:435] fix, added an extra row containing None
-rw-r--r--lib/sqlalchemy/databases/oracle.py6
-rw-r--r--test/sql/testtypes.py11
2 files changed, 6 insertions, 11 deletions
diff --git a/lib/sqlalchemy/databases/oracle.py b/lib/sqlalchemy/databases/oracle.py
index e1c82450f..8f6ce4772 100644
--- a/lib/sqlalchemy/databases/oracle.py
+++ b/lib/sqlalchemy/databases/oracle.py
@@ -20,6 +20,9 @@ try:
import cx_Oracle
except:
cx_Oracle = None
+
+ORACLE_BINARY_TYPES = [getattr(cx_Oracle, k) for k in ["BFILE", "CLOB", "NCLOB", "BLOB", "LONG_BINARY", "LONG_STRING"] if hasattr(cx_Oracle, k)]
+
class OracleNumeric(sqltypes.Numeric):
def get_col_spec(self):
@@ -326,8 +329,7 @@ class OracleDialect(ansisql.ANSIDialect):
if cursor and cursor.description:
for column in cursor.description:
type_code = column[1]
- if type_code in (cx_Oracle.BFILE, cx_Oracle.CLOB, cx_Oracle.NCLOB,
- cx_Oracle.BLOB, cx_Oracle.LONG_BINARY, cx_Oracle.LONG_STRING):
+ if type_code in ORACLE_BINARY_TYPES:
args['should_prefetch'] = True
break
return args
diff --git a/test/sql/testtypes.py b/test/sql/testtypes.py
index 8606f1b74..e924d08ca 100644
--- a/test/sql/testtypes.py
+++ b/test/sql/testtypes.py
@@ -211,15 +211,8 @@ class BinaryTest(AssertMixin):
stream2 =self.load_stream('binary_data_two.dat')
binary_table.insert().execute(primary_id=1, misc='binary_data_one.dat', data=stream1, data_slice=stream1[0:100], pickled=testobj1)
binary_table.insert().execute(primary_id=2, misc='binary_data_two.dat', data=stream2, data_slice=stream2[0:99], pickled=testobj2)
- if db.name == 'oracle':
- res = binary_table.select().execute()
- l = []
- row = res.fetchone()
- l.append(dict([(k, row[k]) for k in row.keys()]))
- row = res.fetchone()
- l.append(dict([(k, row[k]) for k in row.keys()]))
- else:
- l = binary_table.select().execute().fetchall()
+ binary_table.insert().execute(primary_id=3, misc='binary_data_two.dat', data=None, data_slice=stream2[0:99], pickled=None)
+ l = binary_table.select().execute().fetchall()
print len(stream1), len(l[0]['data']), len(l[0]['data_slice'])
self.assert_(list(stream1) == list(l[0]['data']))
self.assert_(list(stream1[0:100]) == list(l[0]['data_slice']))