Skip to content

Commit 5165a3a

Browse files
Add tests
1 parent 5819902 commit 5165a3a

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

Lib/test/test_sqlite3/test_dbapi.py

+15
Original file line numberDiff line numberDiff line change
@@ -887,6 +887,21 @@ def test_rowcount_executemany(self):
887887
self.cu.executemany("insert into test(name) values (?)", [(1,), (2,), (3,)])
888888
self.assertEqual(self.cu.rowcount, 3)
889889

890+
def test_rowcount_prefixed_with_comment(self):
891+
# gh-79579: rowcount is updated even if query is prefixed with comments
892+
self.cu.execute("/* foo */ insert into test(name) values (?)", ('foo',))
893+
self.assertEqual(self.cu.rowcount, 1)
894+
self.cu.execute("/* bar */ update test set name='bar' where name='foo'")
895+
self.assertEqual(self.cu.rowcount, 2)
896+
897+
@unittest.skipIf(sqlite.sqlite_version_info < (3, 35, 0),
898+
"Requires SQLite 3.35.0 or newer")
899+
def test_rowcount_update_returning(self):
900+
# gh-93421: rowcount is updated correctly for UPDATE...RETURNING queries
901+
self.cu.execute("update test set name='bar' where name='foo' returning 1")
902+
self.assertEqual(self.cu.fetchone()[0], 1)
903+
self.assertEqual(self.cu.rowcount, 1)
904+
890905
def test_total_changes(self):
891906
self.cu.execute("insert into test(name) values ('foo')")
892907
self.cu.execute("insert into test(name) values ('foo')")

0 commit comments

Comments
 (0)