]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
o handle array.ArrayTypes for Binary on jython
authorPhilip Jenvey <pjenvey@underboss.org>
Sun, 19 Jul 2009 05:39:39 +0000 (05:39 +0000)
committerPhilip Jenvey <pjenvey@underboss.org>
Sun, 19 Jul 2009 05:39:39 +0000 (05:39 +0000)
o tag zxjdbc as lacking datetime microsecond support

lib/sqlalchemy/types.py
test/sql/test_types.py

index 8d123f50484b89d2896e6128ab487748b83afb9c..1a7e90644ad336b9f4518fe27f01cc51d6d2ca98 100644 (file)
@@ -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):
index bac6eb509422d05cae1640b007e90c6b0bdc55b0..cffb86fdc2b6420e5edc554325c3d2bde53a47c1 100644 (file)
@@ -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'):