From: Philip Jenvey Date: Sun, 19 Jul 2009 05:39:39 +0000 (+0000) Subject: o handle array.ArrayTypes for Binary on jython X-Git-Tag: rel_0_6_6~106 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=dad152fe34de387d30a4c413b7160532a4ce4891;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git o handle array.ArrayTypes for Binary on jython o tag zxjdbc as lacking datetime microsecond support --- diff --git a/lib/sqlalchemy/types.py b/lib/sqlalchemy/types.py index 8d123f5048..1a7e90644a 100644 --- a/lib/sqlalchemy/types.py +++ b/lib/sqlalchemy/types.py @@ -30,6 +30,8 @@ from sqlalchemy.util import pickle from sqlalchemy.sql.visitors import Visitable import sqlalchemy.util as util NoneType = type(None) +if util.jython: + import array class AbstractType(Visitable): @@ -842,7 +844,11 @@ class PickleType(MutableType, TypeDecorator): # Py3K #return loads(value) # Py2K - return loads(str(value)) + if util.jython and isinstance(value, array.ArrayType): + value = value.tostring() + else: + value = str(value) + return loads(value) # end Py2K def copy_value(self, value): diff --git a/test/sql/test_types.py b/test/sql/test_types.py index bac6eb5094..cffb86fdc2 100644 --- a/test/sql/test_types.py +++ b/test/sql/test_types.py @@ -403,10 +403,19 @@ class BinaryTest(TestBase, AssertsExecutionResults): binary_table.select(order_by=binary_table.c.primary_id), text("select * from binary_table order by binary_table.primary_id", typemap={'pickled':PickleType, 'mypickle':MyPickleType}, bind=testing.db) ): + eq_data = lambda x, y: eq_(list(x), list(y)) + if util.jython: + _eq_data = eq_data + def eq_data(x, y): + # Jython currently returns arrays + from array import ArrayType + if isinstance(y, ArrayType): + return eq_(x, y.tostring()) + return _eq_data(x, y) l = stmt.execute().fetchall() - eq_(list(stream1), list(l[0]['data'])) - eq_(list(stream1[0:100]), list(l[0]['data_slice'])) - eq_(list(stream2), list(l[1]['data'])) + eq_data(stream1, l[0]['data']) + eq_data(stream1[0:100], l[0]['data_slice']) + eq_data(stream2, l[1]['data']) eq_(testobj1, l[0]['pickled']) eq_(testobj2, l[1]['pickled']) eq_(testobj3.moredata, l[0]['mypickle'].moredata) @@ -523,7 +532,7 @@ class DateTest(TestBase, AssertsExecutionResults): time_micro = 999 # Missing or poor microsecond support: - if testing.against('mssql', 'mysql', 'firebird'): + if testing.against('mssql', 'mysql', 'firebird', '+zxjdbc'): datetime_micro, time_micro = 0, 0 # No microseconds for TIME elif testing.against('maxdb'):