summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_sqlite3
diff options
context:
space:
mode:
authorErlend Egeberg Aasland <erlend.aasland@protonmail.com>2022-06-08 10:43:54 (GMT)
committerGitHub <noreply@github.com>2022-06-08 10:43:54 (GMT)
commit875de61c296604f3a3a51e9d76355e0f1a24c6af (patch)
tree6546149ce452070ea70e9f09ad1ca8c06213c1b0 /Lib/test/test_sqlite3
parent5849af7a80166e9e82040e082f22772bd7cf3061 (diff)
downloadcpython-875de61c296604f3a3a51e9d76355e0f1a24c6af.zip
cpython-875de61c296604f3a3a51e9d76355e0f1a24c6af.tar.gz
cpython-875de61c296604f3a3a51e9d76355e0f1a24c6af.tar.bz2
gh-93421: Update sqlite3 cursor.rowcount only after SQLITE_DONE (#93526)
Diffstat (limited to 'Lib/test/test_sqlite3')
-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 b958bf1..05180a3 100644
--- a/Lib/test/test_sqlite3/test_dbapi.py
+++ b/Lib/test/test_sqlite3/test_dbapi.py
@@ -898,6 +898,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')")