File tree Expand file tree Collapse file tree 2 files changed +8
-2
lines changed Expand file tree Collapse file tree 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):
282282 """Fetch several rows."""
283283 self ._check_executed ()
284284 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
285287 return ()
286288 end = self .rownumber + (size or self .arraysize )
287289 result = self ._rows [self .rownumber : end ]
@@ -292,7 +294,7 @@ def fetchall(self):
292294 """Fetch all the rows."""
293295 self ._check_executed ()
294296 if self ._rows is None :
295- return ()
297+ return []
296298 if self .rownumber :
297299 result = self ._rows [self .rownumber :]
298300 else :
@@ -479,6 +481,10 @@ def fetchmany(self, size=None):
479481 break
480482 rows .append (row )
481483 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 ()
482488 return rows
483489
484490 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):
3838 self .assertEqual ([(i ,)], list (cur ))
3939 with self .assertRaises (pymysql .ProgrammingError ):
4040 cur .nextset ()
41- self .assertEqual (() , cur .fetchall ())
41+ self .assertEqual ([] , cur .fetchall ())
4242
4343 def test_ok_and_next (self ):
4444 cur = self .connect (client_flag = CLIENT .MULTI_STATEMENTS ).cursor ()
You can’t perform that action at this time.
0 commit comments