Skip to content

Commit

Permalink
revert connection as returned value
Browse files Browse the repository at this point in the history
  • Loading branch information
kalombos committed May 6, 2024
1 parent 16e14d8 commit c448560
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions peewee_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,6 @@ async def __aexit__(self, exc_type, exc_value, exc_tb):
await self.rollback()
else:
await self.commit()
self.connection_context.transactions.pop()

async def commit(self):

Expand Down Expand Up @@ -636,10 +635,10 @@ async def __aenter__(self):

async def __aexit__(self, exc_type, exc_value, exc_tb):
await self.transaction.__aexit__(exc_type, exc_value, exc_tb)
self.connection_context.transactions.pop()
await super().__aexit__()



class AsyncDatabase:
_allow_sync = True # whether sync queries are allowed

Expand Down Expand Up @@ -781,8 +780,7 @@ def connection(self) -> ConnectionContextManager:
async def aio_execute_sql(self, sql: str, params=None, fetch_results=None):
__log__.debug(sql, params)
with peewee.__exception_wrapper__:
async with self.connection() as _connection_context:
connection = connection_context.connection
async with self.connection() as connection:
async with connection.cursor() as cursor:
await cursor.execute(sql, params or ())
if fetch_results is not None:
Expand Down

0 comments on commit c448560

Please sign in to comment.