File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -505,8 +505,8 @@ cdef class Cursor:
505505
506506 try :
507507 return self .getrow()
508-
509508 except StopIteration :
509+ self ._rownumber = self ._source._conn.rows_affected
510510 return None
511511 except _mssql.MSSQLDatabaseException, e:
512512 raise OperationalError, e.args[0 ]
@@ -527,6 +527,7 @@ cdef class Cursor:
527527 try :
528528 rows.append(self .getrow())
529529 except StopIteration :
530+ self ._rownumber = self ._source._conn.rows_affected
530531 break
531532 return rows
532533 except _mssql.MSSQLDatabaseException, e:
Original file line number Diff line number Diff line change @@ -285,6 +285,24 @@ def test_select_rowcount(self):
285285 cur .fetchall ()
286286 eq_ (cur .rowcount , 5 )
287287
288+ def test_fetchone_rowcount (self ):
289+ cur = self .execute ('select * from test' )
290+ eq_ (cur .rowcount , - 1 )
291+
292+ for _ in iter (cur .fetchone , None ):
293+ eq_ (cur .rowcount , - 1 )
294+
295+ eq_ (cur .rowcount , 5 )
296+
297+ def test_fetchmany_rowcount (self ):
298+ cur = self .execute ('select * from test' )
299+ eq_ (cur .rowcount , - 1 )
300+
301+ for _ in iter (cur .fetchmany , []):
302+ eq_ (cur .rowcount , - 1 )
303+
304+ eq_ (cur .rowcount , 5 )
305+
288306 def test_as_dict (self ):
289307 # test for http://code.google.com/p/pymssql/issues/detail?id=92
290308 cur = self .conn .cursor (as_dict = True )
You can’t perform that action at this time.
0 commit comments