diff options
| author | Daniele Varrazzo <daniele.varrazzo@gmail.com> | 2017-11-29 15:28:10 +0000 |
|---|---|---|
| committer | Daniele Varrazzo <daniele.varrazzo@gmail.com> | 2017-11-29 15:42:04 +0000 |
| commit | 65ed5478d126d83a11f69a9e13a141185f4c0f38 (patch) | |
| tree | 35fa1b1f50e80f3b5d1f1d173f04e74e4871b569 /tests/test_cursor.py | |
| parent | 727b952a32ba1715826d0116e14b3c263a4f2920 (diff) | |
| download | psycopg2-65ed5478d126d83a11f69a9e13a141185f4c0f38.tar.gz | |
Collect rowcount in executemany even when discarding results
Closes #633.
Diffstat (limited to 'tests/test_cursor.py')
| -rwxr-xr-x | tests/test_cursor.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/test_cursor.py b/tests/test_cursor.py index e97e817..c5ce70f 100755 --- a/tests/test_cursor.py +++ b/tests/test_cursor.py @@ -583,6 +583,20 @@ class CursorTests(ConnectingTestCase): self.assertEqual(victim_conn.closed, 2) + @skip_before_postgres(8, 2) + def test_rowcount_on_executemany_returning(self): + cur = self.conn.cursor() + cur.execute("create table execmany(id serial primary key, data int)") + cur.executemany( + "insert into execmany (data) values (%s)", + [(i,) for i in range(4)]) + self.assertEqual(cur.rowcount, 4) + + cur.executemany( + "insert into execmany (data) values (%s) returning data", + [(i,) for i in range(5)]) + self.assertEqual(cur.rowcount, 5) + def test_suite(): return unittest.TestLoader().loadTestsFromName(__name__) |
