Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
erlend-aasland committed Jun 5, 2022
1 parent 5819902 commit 5165a3a
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions Lib/test/test_sqlite3/test_dbapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -887,6 +887,21 @@ def test_rowcount_executemany(self):
self.cu.executemany("insert into test(name) values (?)", [(1,), (2,), (3,)])
self.assertEqual(self.cu.rowcount, 3)

def test_rowcount_prefixed_with_comment(self):
# gh-79579: rowcount is updated even if query is prefixed with comments
self.cu.execute("/* foo */ insert into test(name) values (?)", ('foo',))
self.assertEqual(self.cu.rowcount, 1)
self.cu.execute("/* bar */ update test set name='bar' where name='foo'")
self.assertEqual(self.cu.rowcount, 2)

@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')")
Expand Down

0 comments on commit 5165a3a

Please sign in to comment.