File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -507,8 +507,8 @@ cdef class Cursor:
507507
508508 try :
509509 return self .getrow()
510-
511510 except StopIteration :
511+ self ._rownumber = self ._source._conn.rows_affected
512512 return None
513513 except _mssql.MSSQLDatabaseException, e:
514514 raise OperationalError, e.args[0 ]
@@ -529,6 +529,7 @@ cdef class Cursor:
529529 try :
530530 rows.append(self .getrow())
531531 except StopIteration :
532+ self ._rownumber = self ._source._conn.rows_affected
532533 break
533534 return rows
534535 except _mssql.MSSQLDatabaseException, e:
Original file line number Diff line number Diff line change @@ -287,6 +287,24 @@ def test_select_rowcount(self):
287287 cur .fetchall ()
288288 eq_ (cur .rowcount , 5 )
289289
290+ def test_fetchone_rowcount (self ):
291+ cur = self .execute ('select * from test' )
292+ eq_ (cur .rowcount , - 1 )
293+
294+ for _ in iter (cur .fetchone , None ):
295+ eq_ (cur .rowcount , - 1 )
296+
297+ eq_ (cur .rowcount , 5 )
298+
299+ def test_fetchmany_rowcount (self ):
300+ cur = self .execute ('select * from test' )
301+ eq_ (cur .rowcount , - 1 )
302+
303+ for _ in iter (cur .fetchmany , []):
304+ eq_ (cur .rowcount , - 1 )
305+
306+ eq_ (cur .rowcount , 5 )
307+
290308 def test_as_dict (self ):
291309 # test for http://code.google.com/p/pymssql/issues/detail?id=92
292310 cur = self .conn .cursor (as_dict = True )
You can’t perform that action at this time.
0 commit comments