diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2014-07-22 13:41:47 -0400 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2014-07-22 13:42:38 -0400 |
commit | 63c6aa01040831f2bad52c1f7099a78676ac207a (patch) | |
tree | a7e8f6cfb73d3895badfa19ee42da0640e14b328 | |
parent | 76e127450c4bb7047a9babd5263a80e3c6f4cbf9 (diff) | |
download | sqlalchemy-63c6aa01040831f2bad52c1f7099a78676ac207a.tar.gz |
- update some SQL server tests, support
- add support for IDENTITY INSERT setting for INSERT with inline VALUES
-rw-r--r-- | doc/build/changelog/changelog_09.rst | 4 | ||||
-rw-r--r-- | lib/sqlalchemy/dialects/mssql/base.py | 18 | ||||
-rw-r--r-- | test/requirements.py | 10 | ||||
-rw-r--r-- | test/sql/test_join_rewriting.py | 2 | ||||
-rw-r--r-- | test/sql/test_types.py | 10 |
5 files changed, 37 insertions, 7 deletions
diff --git a/doc/build/changelog/changelog_09.rst b/doc/build/changelog/changelog_09.rst index 326779d4a..0f01c7e2a 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 f4264b3d0..d1d4cb9ca 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 f4fd6b601..f91c8f68a 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 035f60d60..c8b24e2f2 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 852591543..b88edbe59 100644 --- a/test/sql/test_types.py +++ b/test/sql/test_types.py @@ -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' |