Skip to content

Commit e0228c5

Browse files
fixup! Fix get_results_from_sfqid with DictCursor + multi statements (#2531)
1 parent f9c022d commit e0228c5

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

src/snowflake/connector/aio/_cursor.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ def __init__(
7676
super().__init__(connection, use_dict_result)
7777
# the following fixes type hint
7878
self._connection = typing.cast("SnowflakeConnection", self._connection)
79-
self._inner_cursor = typing.cast(SnowflakeCursor, self._inner_cursor)
79+
self._inner_cursor: SnowflakeCursor | None = None
8080
self._lock_canceling = asyncio.Lock()
8181
self._timebomb: asyncio.Task | None = None
8282
self._prefetch_hook: typing.Callable[[], typing.Awaitable] | None = None
@@ -958,7 +958,7 @@ async def fetchall(self) -> list[tuple] | list[dict]:
958958
await self._prefetch_hook()
959959
if self._result is None and self._result_set is not None:
960960
self._result: ResultSetIterator = await self._result_set._create_iter(
961-
is_fetch_all=True
961+
is_fetch_all=True,
962962
)
963963
self._result_state = ResultState.VALID
964964

test/integ/aio_it/test_multi_statement_async.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,15 +154,14 @@ async def test_async_exec_multi(conn_cnx, cursor_class, skip_to_last_set: bool):
154154
assert con.is_still_running(await con.get_query_status(q_id))
155155
await _wait_while_query_running_async(con, q_id, sleep_time=1)
156156
async with conn_cnx() as con:
157-
async with con.cursor() as cur:
157+
async with con.cursor(cursor_class) as cur:
158158
await _wait_until_query_success_async(
159159
con, q_id, num_checks=3, sleep_per_check=1
160160
)
161161
assert (
162162
await con.get_query_status_throw_if_error(q_id) == QueryStatus.SUCCESS
163163
)
164164

165-
await cur.get_results_from_sfqid(q_id)
166165
if cursor_class == SnowflakeCursor:
167166
expected = [
168167
[(1,)],
@@ -177,6 +176,9 @@ async def test_async_exec_multi(conn_cnx, cursor_class, skip_to_last_set: bool):
177176
lambda x: len(x) == 1 and len(x[0]) == 1 and x[0]["COUNT(*)"] > 0,
178177
[{"'B'": "b"}],
179178
]
179+
180+
await cur.get_results_from_sfqid(q_id)
181+
assert isinstance(cur, cursor_class)
180182
await _check_multi_statement_results(
181183
cur,
182184
checks=expected,

0 commit comments

Comments
 (0)