@@ -168,7 +168,7 @@ def _handle_result(self, result):
168
168
"""Handles the result after statement execution"""
169
169
if 'columns' in result :
170
170
self ._description = result ['columns' ]
171
- self ._rowcount = 0
171
+ self ._rowcount = - 1
172
172
self ._handle_resultset ()
173
173
else :
174
174
self ._insert_id = result ['insert_id' ]
@@ -515,7 +515,10 @@ def fetchall(self):
515
515
self ._handle_eof ()
516
516
return []
517
517
518
- self ._rowcount += len (rows [0 ])
518
+ rowcount = len (rows [0 ])
519
+ if rowcount >= 0 and self ._rowcount == - 1 :
520
+ self ._rowcount = 0
521
+ self ._rowcount += rowcount
519
522
self ._handle_eof ()
520
523
#self._cnx.handle_unread_result()
521
524
return rows [0 ]
@@ -545,7 +548,10 @@ def fetchmany(self, size=1):
545
548
self ._handle_eof ()
546
549
return []
547
550
548
- self ._rowcount += len (rows )
551
+ rowcount = len (rows )
552
+ if rowcount >= 0 and self ._rowcount == - 1 :
553
+ self ._rowcount = 0
554
+ self ._rowcount += rowcount
549
555
return rows
550
556
551
557
def fetchone (self ):
@@ -562,7 +568,10 @@ def fetchone(self):
562
568
else :
563
569
self ._handle_eof ()
564
570
return None
565
- self ._rowcount += 1
571
+ if self ._rowcount == - 1 :
572
+ self ._rowcount = 1
573
+ else :
574
+ self ._rowcount += 1
566
575
return row [0 ]
567
576
568
577
def __iter__ (self ):
@@ -839,7 +848,7 @@ class CMySQLCursorPrepared(CMySQLCursor):
839
848
def __init__ (self , connection ):
840
849
super (CMySQLCursorPrepared , self ).__init__ (connection )
841
850
self ._rows = None
842
- self ._rowcount = 0
851
+ self ._rowcount = - 1
843
852
self ._next_row = 0
844
853
self ._binary = True
845
854
self ._stmt = None
@@ -1041,6 +1050,9 @@ def fetchall(self):
1041
1050
self ._handle_eof ()
1042
1051
return []
1043
1052
1044
- self ._rowcount += len (rows [0 ])
1053
+ rowcount = len (rows [0 ])
1054
+ if rowcount >= 0 and self ._rowcount == - 1 :
1055
+ self ._rowcount = 0
1056
+ self ._rowcount += rowcount
1045
1057
self ._handle_eof ()
1046
1058
return rows [0 ]
0 commit comments