Skip to content

Commit 8c2e1f9

Browse files
authored
test: Fix insert rowcount (#242)
1 parent 2e70667 commit 8c2e1f9

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

src/firebolt/async_db/cursor.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,10 +303,12 @@ def _row_set_from_response(
303303
# Skip parsing floats to properly parse them later
304304
query_data = response.json(parse_float=str)
305305
rowcount = int(query_data["rows"])
306-
descriptions = [
306+
descriptions: Optional[List[Column]] = [
307307
Column(d["name"], parse_type(d["type"]), None, None, None, None, None)
308308
for d in query_data["meta"]
309309
]
310+
if not descriptions:
311+
descriptions = None
310312
statistics = Statistics(**query_data["statistics"])
311313
# Parse data during fetch
312314
rows = query_data["data"]

tests/integration/dbapi/async/test_queries_async.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -388,9 +388,9 @@ async def test_multi_statement_query(connection: Connection) -> None:
388388
"SELECT * FROM test_tb_async_multi_statement;"
389389
"SELECT * FROM test_tb_async_multi_statement WHERE i <= 1"
390390
)
391-
== -1
391+
== 1 # Insert always returns 1 row with num of rows modified
392392
), "Invalid row count returned for insert"
393-
assert c.rowcount == -1, "Invalid row count"
393+
assert c.rowcount == 1, "Invalid row count"
394394
assert c.description is None, "Invalid description"
395395

396396
assert await c.nextset()

tests/integration/dbapi/sync/test_queries.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -333,9 +333,9 @@ def test_multi_statement_query(connection: Connection) -> None:
333333
"SELECT * FROM test_tb_multi_statement;"
334334
"SELECT * FROM test_tb_multi_statement WHERE i <= 1"
335335
)
336-
== -1
336+
== 1 # Insert always returns 1 row with num of rows modified
337337
), "Invalid row count returned for insert"
338-
assert c.rowcount == -1, "Invalid row count"
338+
assert c.rowcount == 1, "Invalid row count"
339339
assert c.description is None, "Invalid description"
340340

341341
assert c.nextset()

0 commit comments

Comments
 (0)