]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- break out binary insert against None, disable for freetds for now
authorMike Bayer <mike_mp@zzzcomputing.com>
Sun, 24 May 2015 21:08:02 +0000 (17:08 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Sun, 24 May 2015 21:08:02 +0000 (17:08 -0400)
test/dialect/mssql/test_types.py
test/requirements.py

index 5c9157379490296443e5376a9d9d068a3e4372e0..a0f674a6152a53cb1a229b201eaa4935e593509a 100644 (file)
@@ -772,18 +772,6 @@ class BinaryTest(fixtures.TestBase, AssertsExecutionResults):
             pickled=testobj2,
         )
 
-        # TODO: pyodbc does not seem to accept "None" for a VARBINARY
-        # column (data=None). error:  [Microsoft][ODBC SQL Server
-        # Driver][SQL Server]Implicit conversion from data type varchar
-        # to varbinary is not allowed. Use the CONVERT function to run
-        # this query. (257) binary_table.insert().execute(primary_id=3,
-        # misc='binary_data_two.dat', data=None, data_image=None,
-        # data_slice=stream2[0:99], pickled=None)
-
-        binary_table.insert().execute(
-            primary_id=3,
-            misc='binary_data_two.dat', data_image=None,
-            data_slice=stream2[0:99], pickled=None)
         for stmt in \
             binary_table.select(order_by=binary_table.c.primary_id), \
                 text(
@@ -807,6 +795,43 @@ class BinaryTest(fixtures.TestBase, AssertsExecutionResults):
             eq_(testobj3.moredata, l[0]['mypickle'].moredata)
             eq_(l[0]['mypickle'].stuff, 'this is the right stuff')
 
+    @testing.requires.no_mssql_freetds
+    def test_binary_none(self):
+        # TODO: pyodbc does not seem to accept "None" for a VARBINARY
+        # column (data=None). error:  [Microsoft][ODBC SQL Server
+        # Driver][SQL Server]Implicit conversion from data type varchar
+        # to varbinary is not allowed. Use the CONVERT function to run
+        # this query. (257) binary_table.insert().execute(primary_id=3,
+        # misc='binary_data_two.dat', data=None, data_image=None,
+        # data_slice=stream2[0:99], pickled=None)
+
+        stream2 = self.load_stream('binary_data_two.dat')
+
+        binary_table.insert().execute(
+            primary_id=3,
+            misc='binary_data_two.dat', data_image=None,
+            data_slice=stream2[0:99], pickled=None)
+        for stmt in \
+            binary_table.select(), \
+                text(
+                    'select * from binary_table',
+                    typemap=dict(
+                        data=mssql.MSVarBinary(8000),
+                        data_image=mssql.MSImage,
+                        data_slice=types.BINARY(100), pickled=PickleType,
+                        mypickle=MyPickleType),
+                    bind=testing.db):
+            row = stmt.execute().first()
+            eq_(
+                row['pickled'], None
+            )
+            eq_(
+                row['data_image'], None
+            )
+            eq_(
+                row['data_slice'], stream2[0:99]
+            )
+
     def load_stream(self, name, len=3000):
         fp = open(
             os.path.join(os.path.dirname(__file__), "..", "..", name), 'rb')
index e993be2e7258bdd71bc9f93448a15e3e578e7bea..db5e65f4c09d11f99e084eb3881c230b9bfbadb1 100644 (file)
@@ -810,12 +810,15 @@ class DefaultRequirements(SuiteRequirements):
             )
         )
 
+    @property
+    def no_mssql_freetds(self):
+        return self.mssql_freetds.not_()
+
     @property
     def selectone(self):
         """target driver must support the literal statement 'select 1'"""
         return skip_if(["oracle", "firebird"], "non-standard SELECT scalar syntax")
 
-
     @property
     def mysql_fully_case_sensitive(self):
         return only_if(self._has_mysql_fully_case_sensitive)