mirror of
				https://github.com/psycopg/psycopg2.git
				synced 2025-10-31 07:47:30 +03:00 
			
		
		
		
	Added test for scrollable cursor
This commit is contained in:
		
							parent
							
								
									fa4994e471
								
							
						
					
					
						commit
						d074b096be
					
				|  | @ -213,6 +213,45 @@ class CursorTests(unittest.TestCase): | |||
|         curs.execute("drop table withhold") | ||||
|         self.conn.commit() | ||||
| 
 | ||||
|     def test_scrollable(self): | ||||
|         self.assertRaises(psycopg2.ProgrammingError, self.conn.cursor, | ||||
|                           scrollable=True) | ||||
| 
 | ||||
|         curs = self.conn.cursor() | ||||
|         curs.execute("create table scrollable (data int)") | ||||
|         curs.executemany("insert into scrollable values (%s)", | ||||
|             [ (i,) for i in range(100) ]) | ||||
|         curs.close() | ||||
| 
 | ||||
|         for t in range(2): | ||||
|             if not t: | ||||
|                 curs = self.conn.cursor("S") | ||||
|                 self.assertEqual(curs.scrollable, False); | ||||
|                 curs.scrollable = True | ||||
|             else: | ||||
|                 curs = self.conn.cursor("S", scrollable=True) | ||||
| 
 | ||||
|             self.assertEqual(curs.scrollable, True); | ||||
|             curs.itersize = 10 | ||||
| 
 | ||||
|             # complex enough to make postgres cursors declare without | ||||
|             # scroll/no scroll to fail | ||||
|             curs.execute(""" | ||||
|                 select x.data | ||||
|                 from scrollable x | ||||
|                 join scrollable y on x.data = y.data | ||||
|                 order by y.data""") | ||||
|             for i, (n,) in enumerate(curs): | ||||
|                 self.assertEqual(i, n) | ||||
| 
 | ||||
|             curs.scroll(-1) | ||||
|             for i in range(99, -1, -1): | ||||
|                 curs.scroll(-1) | ||||
|                 self.assertEqual(i, curs.fetchone()[0]) | ||||
|                 curs.scroll(-1) | ||||
| 
 | ||||
|             curs.close() | ||||
| 
 | ||||
|     @skip_before_postgres(8, 2) | ||||
|     def test_iter_named_cursor_efficient(self): | ||||
|         curs = self.conn.cursor('tmp') | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	Block a user