summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2022-06-08 11:07:15 (GMT)
committerGitHub <noreply@github.com>2022-06-08 11:07:15 (GMT)
commit68aae80159996374509b98b6345ff9b72743b4d9 (patch)
tree6e4517fb19956d842121378edbeddec3af87f1ff /Lib/test
parent121ab58e03924161df6fd0002ef7bfd45404cb2e (diff)
downloadcpython-68aae80159996374509b98b6345ff9b72743b4d9.zip
cpython-68aae80159996374509b98b6345ff9b72743b4d9.tar.gz
cpython-68aae80159996374509b98b6345ff9b72743b4d9.tar.bz2
gh-93421: Update sqlite3 cursor.rowcount only after SQLITE_DONE (GH-93526)
(cherry picked from commit 875de61c296604f3a3a51e9d76355e0f1a24c6af) Co-authored-by: Erlend Egeberg Aasland <erlend.aasland@protonmail.com>
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_sqlite3/test_dbapi.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/Lib/test/test_sqlite3/test_dbapi.py b/Lib/test/test_sqlite3/test_dbapi.py
index e514adb..39dbbb9 100644
--- a/Lib/test/test_sqlite3/test_dbapi.py
+++ b/Lib/test/test_sqlite3/test_dbapi.py
@@ -903,6 +903,14 @@ class CursorTests(unittest.TestCase):
self.cu.executemany("insert into test(name) values (?)", [(1,), (2,), (3,)])
self.assertEqual(self.cu.rowcount, 3)
+ @unittest.skipIf(sqlite.sqlite_version_info < (3, 35, 0),
+ "Requires SQLite 3.35.0 or newer")
+ def test_rowcount_update_returning(self):
+ # gh-93421: rowcount is updated correctly for UPDATE...RETURNING queries
+ self.cu.execute("update test set name='bar' where name='foo' returning 1")
+ self.assertEqual(self.cu.fetchone()[0], 1)
+ self.assertEqual(self.cu.rowcount, 1)
+
def test_total_changes(self):
self.cu.execute("insert into test(name) values ('foo')")
self.cu.execute("insert into test(name) values ('foo')")