Skip to content

Commit 091d641

Browse files
committed
fix other tests
1 parent 4ce646a commit 091d641

File tree

4 files changed

+19
-7
lines changed

4 files changed

+19
-7
lines changed

src/firebolt/async_db/connection.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,9 +230,15 @@ async def _execute_query(self, request: Request) -> Response:
230230
return await self._execute_query_impl(request)
231231

232232
async def commit(self) -> None:
233-
await self.cursor().execute("COMMIT")
233+
if self.closed:
234+
raise ConnectionClosedError("Unable to commit: Connection closed.")
235+
# Commit is a no-op for V1
236+
if not self.cursor_type == CursorV1:
237+
await self.cursor().execute("COMMIT")
234238

235239
async def rollback(self) -> None:
240+
if self.closed:
241+
raise ConnectionClosedError("Unable to rollback: Connection closed.")
236242
await self.cursor().execute("ROLLBACK")
237243

238244
# Context manager support

src/firebolt/db/connection.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,9 +311,15 @@ def _execute_query(self, request: Request) -> Response:
311311
return self._execute_query_impl(request)
312312

313313
def commit(self) -> None:
314-
self.cursor().execute("COMMIT")
314+
if self.closed:
315+
raise ConnectionClosedError("Unable to commit: Connection closed.")
316+
# Commit is a no-op for V1
317+
if not self.cursor_type == CursorV1:
318+
self.cursor().execute("COMMIT")
315319

316320
def rollback(self) -> None:
321+
if self.closed:
322+
raise ConnectionClosedError("Unable to rollback: Connection closed.")
317323
self.cursor().execute("ROLLBACK")
318324

319325
# Server-side async methods

tests/unit/V1/async_db/test_connection.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -279,11 +279,11 @@ async def test_connect_default_engine(
279279

280280
async def test_connection_commit(connection: Connection):
281281
# nothing happens
282-
connection.commit()
282+
await connection.commit()
283283

284284
await connection.aclose()
285285
with raises(ConnectionClosedError):
286-
connection.commit()
286+
await connection.commit()
287287

288288

289289
@mark.nofakefs

tests/unit/common/test_base_cursor.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33

44
from pytest import fixture, mark
55

6-
from firebolt.common.cursor.base_cursor import (
7-
BaseCursor,
6+
from firebolt.common.cursor.base_cursor import BaseCursor
7+
from firebolt.common.statement_formatter import create_statement_formatter
8+
from firebolt.utils.util import (
89
_parse_remove_parameters,
910
_parse_update_parameters,
1011
)
11-
from firebolt.common.statement_formatter import create_statement_formatter
1212

1313

1414
@fixture

0 commit comments

Comments
 (0)