]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- update some SQL server tests, support
authorMike Bayer <mike_mp@zzzcomputing.com>
Tue, 22 Jul 2014 17:41:47 +0000 (13:41 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Tue, 22 Jul 2014 17:42:38 +0000 (13:42 -0400)
- add support for IDENTITY INSERT setting for INSERT with inline VALUES

doc/build/changelog/changelog_09.rst
lib/sqlalchemy/dialects/mssql/base.py
test/requirements.py
test/sql/test_join_rewriting.py
test/sql/test_types.py

index 326779d4af1c1035872fec33914c24b16685a89b..0f01c7e2a531e6dcf328d228f15f0efdc0cf0083 100644 (file)
         :versions: 1.0.0
 
         Enabled "multivalues insert" for SQL Server 2008.  Pull request
-        courtesy Albert Cervin.
+        courtesy Albert Cervin.  Also expanded the checks for "IDENTITY INSERT"
+        mode to include when the identity key is present in the
+        VALUEs clause of the statement.
 
     .. change::
         :tags: feature, engine
index f4264b3d0cb354a75353f4bb76bd7a0dfd35c511..d1d4cb9ca6115b8ee13da9d2b8391ca8826a820d 100644 (file)
@@ -769,7 +769,23 @@ class MSExecutionContext(default.DefaultExecutionContext):
 
             if insert_has_sequence:
                 self._enable_identity_insert = \
-                    seq_column.key in self.compiled_parameters[0]
+                    seq_column.key in self.compiled_parameters[0] or \
+                    (
+                        self.compiled.statement.parameters and (
+                            (
+                                self.compiled.statement._has_multi_parameters
+                                and
+                                seq_column.key in
+                                self.compiled.statement.parameters[0]
+                            ) or (
+                                not
+                                self.compiled.statement._has_multi_parameters
+                                and
+                                seq_column.key in
+                                self.compiled.statement.parameters
+                            )
+                        )
+                    )
             else:
                 self._enable_identity_insert = False
 
index f4fd6b601af893b39d113eaaf22e39d2161e50fc..f91c8f68a5315bd168d3c4a25c5f776461f65e23 100644 (file)
@@ -403,13 +403,19 @@ class DefaultRequirements(SuiteRequirements):
     def unicode_ddl(self):
         """Target driver must support some degree of non-ascii symbol names."""
         # TODO: expand to exclude MySQLdb versions w/ broken unicode
+
         return skip_if([
             no_support('oracle', 'FIXME: no support in database?'),
             no_support('sybase', 'FIXME: guessing, needs confirmation'),
             no_support('mssql+pymssql', 'no FreeTDS support'),
-
+            LambdaPredicate(
+                lambda config: against(config, 'mssql+pyodbc') and
+                config.db.dialect.freetds and
+                config.db.dialect.freetds_driver_version < "0.91",
+                "older freetds doesn't support unicode DDL"
+            ),
             exclude('mysql', '<', (4, 1, 1), 'no unicode connection support'),
-            ])
+        ])
 
     @property
     def sane_rowcount(self):
index 035f60d602ffe9bbe7be2503e65f0f2f4a6b1c7b..c8b24e2f2af07b4c6967f86eed840c27314dd7cb 100644 (file)
@@ -631,6 +631,8 @@ class JoinExecTest(_JoinRewriteTestBase, fixtures.TestBase):
             assert col in result._metadata._keymap
 
     @testing.skip_if("oracle", "oracle's cranky")
+    @testing.skip_if("mssql", "can't query EXISTS in the columns "
+                     "clause w/o subquery")
     def test_a_atobalias_balias_c_w_exists(self):
         super(JoinExecTest, self).test_a_atobalias_balias_c_w_exists()
 
index 852591543fc798ca62df2df6a8945804409831e1..b88edbe59072951f4f57602078ed14317d9a5491 100644 (file)
@@ -900,9 +900,13 @@ class UnicodeTest(fixtures.TestBase):
     def test_native_unicode(self):
         """assert expected values for 'native unicode' mode"""
 
-        if (testing.against('mssql+pyodbc') and
-                not testing.db.dialect.freetds) \
-                or testing.against('mssql+mxodbc'):
+        if testing.against('mssql+pyodbc'):
+            eq_(
+                testing.db.dialect.returns_unicode_strings,
+                'conditional'
+            )
+
+        elif testing.against('mssql+mxodbc'):
             eq_(
                 testing.db.dialect.returns_unicode_strings,
                 'conditional'