diff options
| author | Daniele Varrazzo <daniele.varrazzo@gmail.com> | 2012-02-23 22:04:22 +0000 |
|---|---|---|
| committer | Daniele Varrazzo <daniele.varrazzo@gmail.com> | 2012-02-23 22:04:22 +0000 |
| commit | 7221ea9ec57728b9afb1c5e42f4a509dad9da29b (patch) | |
| tree | abc9d4269cb9d73cf18ab2355e0ae25fdb963c57 /tests/test_cursor.py | |
| parent | 71d1690870954ec9a3c83d275fe439e5b591c299 (diff) | |
| download | psycopg2-7221ea9ec57728b9afb1c5e42f4a509dad9da29b.tar.gz | |
Added test to check rowcount behaves fine during named cursor iteration
Actually *it doesn't*: once we iterate the first itersize records, rowcount
is reset to zero. If we want to fix it we need an extra member in the
cursor.
Diffstat (limited to 'tests/test_cursor.py')
| -rwxr-xr-x | tests/test_cursor.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/tests/test_cursor.py b/tests/test_cursor.py index 5cb9b7e..6286942 100755 --- a/tests/test_cursor.py +++ b/tests/test_cursor.py @@ -234,6 +234,17 @@ class CursorTests(unittest.TestCase): # everything swallowed in two gulps self.assertEqual(rv, [(i,((i - 1) % 30) + 1) for i in range(1,51)]) + @skip_before_postgres(8, 0) + def test_iter_named_cursor_rownumber(self): + curs = self.conn.cursor('tmp') + # note: this fails if itersize < dataset: internally we check + # rownumber == rowcount to detect when to read anoter page, so we + # would need an extra attribute to have a monotonic rownumber. + curs.itersize = 20 + curs.execute('select generate_series(1,10)') + for i, rec in enumerate(curs): + self.assertEqual(i + 1, curs.rownumber) + @skip_if_no_namedtuple def test_namedtuple_description(self): curs = self.conn.cursor() |
