File tree 2 files changed +8
-2
lines changed
2 files changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -282,6 +282,8 @@ def fetchmany(self, size=None):
282
282
"""Fetch several rows."""
283
283
self ._check_executed ()
284
284
if self ._rows is None :
285
+ # Django expects () for EOF.
286
+ # https://github.com/django/django/blob/0c1518ee429b01c145cf5b34eab01b0b92f8c246/django/db/backends/mysql/features.py#L8
285
287
return ()
286
288
end = self .rownumber + (size or self .arraysize )
287
289
result = self ._rows [self .rownumber : end ]
@@ -292,7 +294,7 @@ def fetchall(self):
292
294
"""Fetch all the rows."""
293
295
self ._check_executed ()
294
296
if self ._rows is None :
295
- return ()
297
+ return []
296
298
if self .rownumber :
297
299
result = self ._rows [self .rownumber :]
298
300
else :
@@ -479,6 +481,10 @@ def fetchmany(self, size=None):
479
481
break
480
482
rows .append (row )
481
483
self .rownumber += 1
484
+ if not rows :
485
+ # Django expects () for EOF.
486
+ # https://github.com/django/django/blob/0c1518ee429b01c145cf5b34eab01b0b92f8c246/django/db/backends/mysql/features.py#L8
487
+ return ()
482
488
return rows
483
489
484
490
def scroll (self , value , mode = "relative" ):
Original file line number Diff line number Diff line change @@ -38,7 +38,7 @@ def test_nextset_error(self):
38
38
self .assertEqual ([(i ,)], list (cur ))
39
39
with self .assertRaises (pymysql .ProgrammingError ):
40
40
cur .nextset ()
41
- self .assertEqual (() , cur .fetchall ())
41
+ self .assertEqual ([] , cur .fetchall ())
42
42
43
43
def test_ok_and_next (self ):
44
44
cur = self .connect (client_flag = CLIENT .MULTI_STATEMENTS ).cursor ()
You can’t perform that action at this time.
0 commit comments