Skip to content

Commit b47bef6

Browse files
authored
ensure coroutine is awaited when discarding results in SSCursor, fixes #635 (#701)
also fix typo in associated test case
1 parent 018af44 commit b47bef6

3 files changed

Lines changed: 4 additions & 8 deletions

File tree

CHANGES.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ To be included in 1.0.0 (unreleased)
1212
* Ensure connections are properly closed before raising an InternalError when packet sequence numbers are out of sync #660
1313
* Unix sockets are now internally considered secure, allowing sha256_password and caching_sha2_password auth methods to be used #695
1414
* Test suite now also tests unix socket connections #696
15+
* Fix SSCursor raising InternalError when last result was not fully retrieved #635
1516

1617

1718
0.0.22 (2021-11-14)

aiomysql/connection.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -711,7 +711,7 @@ async def _execute_command(self, command, sql):
711711
if self._result is not None:
712712
if self._result.unbuffered_active:
713713
warnings.warn("Previous unbuffered result was left incomplete")
714-
self._result._finish_unbuffered_query()
714+
await self._result._finish_unbuffered_query()
715715
while self._result.has_next:
716716
await self.next_result()
717717
self._result = None

tests/test_sscursor.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import asyncio
22

33
import pytest
4-
from pymysql import NotSupportedError, InternalError
4+
from pymysql import NotSupportedError
55

66
from aiomysql import ProgrammingError, InterfaceError
77
from aiomysql.cursors import SSCursor
@@ -190,11 +190,6 @@ async def read_cursor():
190190
await conn.cursor(SSCursor)
191191

192192

193-
@pytest.mark.xfail(
194-
reason="https://github.com/aio-libs/aiomysql/issues/635",
195-
raises=InternalError,
196-
strict=True,
197-
)
198193
@pytest.mark.run_loop
199194
async def test_sscursor_discarded_result(connection):
200195
conn = connection
@@ -203,4 +198,4 @@ async def test_sscursor_discarded_result(connection):
203198
await cursor.execute("select 1")
204199
await cursor.execute("select 2")
205200
ret = await cursor.fetchone()
206-
assert (1,) == ret
201+
assert (2,) == ret

0 commit comments

Comments
 (0)