From: Mike Bayer Date: Sat, 17 Feb 2007 01:18:54 +0000 (+0000) Subject: - fixed oracle list of binary types to check for their presence in the module (such... X-Git-Tag: rel_0_3_5~27 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5f83c55fc7710ad495e64268627949ca91a66c72;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git - 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 --- diff --git a/lib/sqlalchemy/databases/oracle.py b/lib/sqlalchemy/databases/oracle.py index e1c82450fd..8f6ce4772b 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 8606f1b74c..e924d08ca4 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']))