From: Mike Bayer Date: Tue, 22 Jul 2014 17:41:47 +0000 (-0400) Subject: - update some SQL server tests, support X-Git-Tag: rel_0_9_7~4 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=c782fe7eab8252ca7c9f7964e0cbff2ca69b612e;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git - update some SQL server tests, support - add support for IDENTITY INSERT setting for INSERT with inline VALUES --- diff --git a/doc/build/changelog/changelog_09.rst b/doc/build/changelog/changelog_09.rst index 295b084901..e14291d3be 100644 --- a/doc/build/changelog/changelog_09.rst +++ b/doc/build/changelog/changelog_09.rst @@ -174,7 +174,9 @@ :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 diff --git a/lib/sqlalchemy/dialects/mssql/base.py b/lib/sqlalchemy/dialects/mssql/base.py index 29f1d2cde1..3d10904477 100644 --- a/lib/sqlalchemy/dialects/mssql/base.py +++ b/lib/sqlalchemy/dialects/mssql/base.py @@ -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 diff --git a/test/requirements.py b/test/requirements.py index f4fd6b601a..f91c8f68a5 100644 --- a/test/requirements.py +++ b/test/requirements.py @@ -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): diff --git a/test/sql/test_join_rewriting.py b/test/sql/test_join_rewriting.py index 035f60d602..c8b24e2f2a 100644 --- a/test/sql/test_join_rewriting.py +++ b/test/sql/test_join_rewriting.py @@ -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() diff --git a/test/sql/test_types.py b/test/sql/test_types.py index 90b891628b..e2d347928b 100644 --- a/test/sql/test_types.py +++ b/test/sql/test_types.py @@ -896,9 +896,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'