Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion pymysql/cursors.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,8 @@ def fetchmany(self, size=None):
"""Fetch several rows."""
self._check_executed()
if self._rows is None:
# Django expects () for EOF.
# https://github.com/django/django/blob/0c1518ee429b01c145cf5b34eab01b0b92f8c246/django/db/backends/mysql/features.py#L8
return ()
end = self.rownumber + (size or self.arraysize)
result = self._rows[self.rownumber : end]
Expand All @@ -292,7 +294,7 @@ def fetchall(self):
"""Fetch all the rows."""
self._check_executed()
if self._rows is None:
return ()
return []
if self.rownumber:
result = self._rows[self.rownumber :]
else:
Expand Down Expand Up @@ -479,6 +481,10 @@ def fetchmany(self, size=None):
break
rows.append(row)
self.rownumber += 1
if not rows:
# Django expects () for EOF.
# https://github.com/django/django/blob/0c1518ee429b01c145cf5b34eab01b0b92f8c246/django/db/backends/mysql/features.py#L8
return ()
return rows

def scroll(self, value, mode="relative"):
Expand Down
2 changes: 1 addition & 1 deletion pymysql/tests/test_nextset.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def test_nextset_error(self):
self.assertEqual([(i,)], list(cur))
with self.assertRaises(pymysql.ProgrammingError):
cur.nextset()
self.assertEqual((), cur.fetchall())
self.assertEqual([], cur.fetchall())

def test_ok_and_next(self):
cur = self.connect(client_flag=CLIENT.MULTI_STATEMENTS).cursor()
Expand Down