From c6498f16e8012d6215475580f340df4e3eb98c28 Mon Sep 17 00:00:00 2001 From: ptiurin Date: Wed, 15 Mar 2023 13:52:43 +0000 Subject: [PATCH 1/4] test: Fix insert rowcount --- tests/integration/dbapi/async/test_queries_async.py | 4 ++-- tests/integration/dbapi/sync/test_queries.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/integration/dbapi/async/test_queries_async.py b/tests/integration/dbapi/async/test_queries_async.py index 7de7f7ef56d..1d64bfdb64d 100644 --- a/tests/integration/dbapi/async/test_queries_async.py +++ b/tests/integration/dbapi/async/test_queries_async.py @@ -388,9 +388,9 @@ async def test_multi_statement_query(connection: Connection) -> None: "SELECT * FROM test_tb_async_multi_statement;" "SELECT * FROM test_tb_async_multi_statement WHERE i <= 1" ) - == -1 + == 1 # Insert always returns 1 row with num of rows modified ), "Invalid row count returned for insert" - assert c.rowcount == -1, "Invalid row count" + assert c.rowcount == 1, "Invalid row count" assert c.description is None, "Invalid description" assert await c.nextset() diff --git a/tests/integration/dbapi/sync/test_queries.py b/tests/integration/dbapi/sync/test_queries.py index 5d3084c94d5..55ab830d955 100644 --- a/tests/integration/dbapi/sync/test_queries.py +++ b/tests/integration/dbapi/sync/test_queries.py @@ -333,9 +333,9 @@ def test_multi_statement_query(connection: Connection) -> None: "SELECT * FROM test_tb_multi_statement;" "SELECT * FROM test_tb_multi_statement WHERE i <= 1" ) - == -1 + == 1 # Insert always returns 1 row with num of rows modified ), "Invalid row count returned for insert" - assert c.rowcount == -1, "Invalid row count" + assert c.rowcount == 1, "Invalid row count" assert c.description is None, "Invalid description" assert c.nextset() From f1f08190b377eb31c1873a60257cb7fe7493dbe7 Mon Sep 17 00:00:00 2001 From: ptiurin Date: Wed, 15 Mar 2023 16:20:01 +0000 Subject: [PATCH 2/4] no longer special case for insert --- src/firebolt/async_db/cursor.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/firebolt/async_db/cursor.py b/src/firebolt/async_db/cursor.py index fbda088607c..87ef41141d8 100644 --- a/src/firebolt/async_db/cursor.py +++ b/src/firebolt/async_db/cursor.py @@ -296,17 +296,16 @@ def _row_set_from_response( ]: """Fetch information about executed query from http response.""" - # Empty response is returned for insert query - if response.headers.get("content-length", "") == "0": - return (-1, None, None, None) try: # Skip parsing floats to properly parse them later query_data = response.json(parse_float=str) rowcount = int(query_data["rows"]) - descriptions = [ + descriptions: Optional[List[Column]] = [ Column(d["name"], parse_type(d["type"]), None, None, None, None, None) for d in query_data["meta"] ] + if not descriptions: + descriptions = None statistics = Statistics(**query_data["statistics"]) # Parse data during fetch rows = query_data["data"] From 63c39ab4e751ef1485bb8a1d9757c725634dc6ba Mon Sep 17 00:00:00 2001 From: ptiurin Date: Thu, 16 Mar 2023 09:24:42 +0000 Subject: [PATCH 3/4] return the content length --- src/firebolt/async_db/cursor.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/firebolt/async_db/cursor.py b/src/firebolt/async_db/cursor.py index 87ef41141d8..2370743400e 100644 --- a/src/firebolt/async_db/cursor.py +++ b/src/firebolt/async_db/cursor.py @@ -295,7 +295,9 @@ def _row_set_from_response( Optional[List[List[RawColType]]], ]: """Fetch information about executed query from http response.""" - + # Empty response is returned for insert query + if response.headers.get("content-length", "") == "0": + return (-1, None, None, None) try: # Skip parsing floats to properly parse them later query_data = response.json(parse_float=str) From 08ae9862932acdde4a1726bab03582ed2081b87e Mon Sep 17 00:00:00 2001 From: ptiurin Date: Thu, 16 Mar 2023 09:48:46 +0000 Subject: [PATCH 4/4] space --- src/firebolt/async_db/cursor.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/firebolt/async_db/cursor.py b/src/firebolt/async_db/cursor.py index 2370743400e..7ff27a2fd56 100644 --- a/src/firebolt/async_db/cursor.py +++ b/src/firebolt/async_db/cursor.py @@ -295,6 +295,7 @@ def _row_set_from_response( Optional[List[List[RawColType]]], ]: """Fetch information about executed query from http response.""" + # Empty response is returned for insert query if response.headers.get("content-length", "") == "0": return (-1, None, None, None)