.. include:: changelog_07.rst
:start-line: 5
+.. changelog::
+ :version: 1.0.12
+ :released:
+
+ .. change::
+ :tags: bug, mssql, firebird
+ :versions: 1.1.0b1
+ :tickets: 3622
+
+ Fixed 1.0 regression where the eager fetch of cursor.rowcount was
+ no longer called for an UPDATE or DELETE statement emitted via plain
+ text or via the :func:`.text` construct, affecting those drivers
+ that erase cursor.rowcount once the cursor is closed such as SQL
+ Server ODBC and Firebird drivers.
+
+
.. changelog::
:version: 1.0.11
:released: December 22, 2015
if context.compiled:
context.post_exec()
- if context.is_crud:
+ if context.is_crud or context.is_text:
result = context._setup_crud_result_proxy()
else:
result = context.get_result_proxy()
isupdate = False
isdelete = False
is_crud = False
+ is_text = False
isddl = False
executemany = False
compiled = None
self.isinsert = compiled.isinsert
self.isupdate = compiled.isupdate
self.isdelete = compiled.isdelete
+ self.is_text = compiled.isplaintext
if not parameters:
self.compiled_parameters = [compiled.construct_params()]
self.root_connection = connection
self._dbapi_connection = dbapi_connection
self.dialect = connection.dialect
+ self.is_text = True
# plain text statement
self.execution_options = connection._execution_options
def self_group(self, **kw):
return self
+
class SQLCompiler(Compiled):
"""Default implementation of Compiled.
INSERT/UPDATE/DELETE
"""
+ isplaintext = False
+
returning = None
"""holds the "returning" collection of columns if
the statement is CRUD and defines returning columns
else:
return self.bindparam_string(name, **kw)
+ if not self.stack:
+ self.isplaintext = True
+
# un-escape any \:params
return BIND_PARAMS_ESC.sub(
lambda m: m.group(1),
from sqlalchemy import *
from sqlalchemy.testing import fixtures, AssertsExecutionResults
from sqlalchemy import testing
+from sqlalchemy.testing import eq_
class FoundRowsTest(fixtures.TestBase, AssertsExecutionResults):
print("expecting 3, dialect reports %s" % r.rowcount)
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:
+ result = conn.execute(
+ "update employees set department='Z' where department='C'")
+ eq_(result.rowcount, 3)
+
+ def test_text_rowcount(self):
+ # test issue #3622, make sure eager rowcount is called for text
+ with testing.db.connect() as conn:
+ result = conn.execute(
+ text(
+ "update employees set department='Z' "
+ "where department='C'"))
+ eq_(result.rowcount, 3)
+
def test_delete_rowcount(self):
# WHERE matches 3, 3 rows deleted
department = employees_table.c.department