]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
Don't warn on multi delete rowcount if supports_sane_multi is False
authorMike Bayer <mike_mp@zzzcomputing.com>
Fri, 3 May 2019 22:07:06 +0000 (18:07 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Mon, 6 May 2019 21:29:04 +0000 (17:29 -0400)
Fixed an issue where the "number of rows matched" warning would emit even if
the dialect reported "supports_sane_multi_rowcount=False", as is the case
for psycogp2 with ``use_batch_mode=True`` and others.

Fixes: #4661
Change-Id: I93aaf7f597b6083e860ab3cbcd620ba5621c57a8

doc/build/changelog/unreleased_13/4661.rst [new file with mode: 0644]
lib/sqlalchemy/orm/persistence.py
test/orm/test_unitofworkv2.py

diff --git a/doc/build/changelog/unreleased_13/4661.rst b/doc/build/changelog/unreleased_13/4661.rst
new file mode 100644 (file)
index 0000000..f3b1b58
--- /dev/null
@@ -0,0 +1,8 @@
+.. change::
+   :tags: bug, postgresql, orm
+   :tickets: 4661
+
+   Fixed an issue where the "number of rows matched" warning would emit even if
+   the dialect reported "supports_sane_multi_rowcount=False", as is the case
+   for psycogp2 with ``use_batch_mode=True`` and others.
+
index 6345ee28a5ccffaf81aec4583340a051c7652a2f..e9e6975ca3dd1b4d440e30539c62cb1e0143cd29 100644 (file)
@@ -1335,6 +1335,7 @@ def _emit_delete_statements(
 
         if (
             base_mapper.confirm_deleted_rows
+            and connection.dialect.supports_sane_multi_rowcount
             and rows_matched > -1
             and expected != rows_matched
         ):
index 9d7879bb24856b514790421a171bb8c8d7a9afeb..fdb50f37dbb658e67c211ef01835ceb4f4f4a53a 100644 (file)
@@ -1758,6 +1758,24 @@ class BasicStaleChecksTest(fixtures.MappedTest):
             sess.flush,
         )
 
+    def test_delete_multi_broken_multi_rowcount(self):
+        Parent, Child = self._fixture()
+        sess = Session()
+        p1 = Parent(id=1, data=2, child=None)
+        p2 = Parent(id=2, data=3, child=None)
+        sess.add_all([p1, p2])
+        sess.flush()
+
+        sess.execute(self.tables.parent.delete())
+        sess.delete(p1)
+        sess.delete(p2)
+
+        with patch.object(
+            config.db.dialect, "supports_sane_multi_rowcount", False
+        ):
+            # no warning
+            sess.flush()
+
     def test_delete_multi_missing_allow(self):
         Parent, Child = self._fixture(confirm_deleted_rows=False)
         sess = Session()