diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2017-08-31 13:12:50 -0400 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2017-08-31 13:20:57 -0400 |
commit | b9b1e374bfbcece8259a4df5372ca68d45aaaf01 (patch) | |
tree | 6bc5294257c158ffdf4409dde52ff5449c70a79b /test | |
parent | d0470e296ea589620c94d8f2dd37e94b8f03842a (diff) | |
download | sqlalchemy-b9b1e374bfbcece8259a4df5372ca68d45aaaf01.tar.gz |
Add new sane_rowcount_w_returning flag
Added a new class of "rowcount support" for dialects that is specific to
when "RETURNING", which on SQL Server looks like "OUTPUT inserted", is in
use, as the PyODBC backend isn't able to give us rowcount on an UPDATE or
DELETE statement when OUTPUT is in effect. This primarily affects the ORM
when a flush is updating a row that contains server-calcluated values,
raising an error if the backend does not return the expected row count.
PyODBC now states that it supports rowcount except if OUTPUT.inserted is
present, which is taken into account by the ORM during a flush as to
whether it will look for a rowcount.
ORM tests are implicit in existing tests run against PyODBC
Fixes: #4062
Change-Id: Iff17cbe4c7a5742971ed85a4d58660c18cc569c2
Diffstat (limited to 'test')
-rw-r--r-- | test/requirements.py | 14 | ||||
-rw-r--r-- | test/sql/test_rowcount.py | 10 |
2 files changed, 10 insertions, 14 deletions
diff --git a/test/requirements.py b/test/requirements.py index 4f01eac9b..0362e28d1 100644 --- a/test/requirements.py +++ b/test/requirements.py @@ -559,13 +559,6 @@ class DefaultRequirements(SuiteRequirements): ]) @property - def sane_rowcount(self): - return skip_if( - lambda config: not config.db.dialect.supports_sane_rowcount, - "driver doesn't support 'sane' rowcount" - ) - - @property def emulated_lastrowid(self): """"target dialect retrieves cursor.lastrowid or an equivalent after an insert() construct executes. @@ -594,13 +587,6 @@ class DefaultRequirements(SuiteRequirements): 'sqlite+pysqlcipher') @property - def sane_multi_rowcount(self): - return fails_if( - lambda config: not config.db.dialect.supports_sane_multi_rowcount, - "driver %(driver)s %(doesnt_support)s 'sane' multi row count" - ) - - @property def nullsordering(self): """Target backends that support nulls ordering.""" return fails_on_everything_except('postgresql', 'oracle', 'firebird') diff --git a/test/sql/test_rowcount.py b/test/sql/test_rowcount.py index 16087b94c..3399ba7ec 100644 --- a/test/sql/test_rowcount.py +++ b/test/sql/test_rowcount.py @@ -65,6 +65,15 @@ class FoundRowsTest(fixtures.TestBase, AssertsExecutionResults): r = employees_table.update(department == 'C').execute(department='C') assert r.rowcount == 3 + @testing.requires.sane_rowcount_w_returning + def test_update_rowcount_return_defaults(self): + department = employees_table.c.department + stmt = employees_table.update(department == 'C').values( + name=employees_table.c.department + 'Z').return_defaults() + + r = stmt.execute() + assert r.rowcount == 3 + def test_raw_sql_rowcount(self): # test issue #3622, make sure eager rowcount is called for text with testing.db.connect() as conn: @@ -117,3 +126,4 @@ class FoundRowsTest(fixtures.TestBase, AssertsExecutionResults): eq_( r.rowcount, 2 ) + |