Skip to content

Commit 7f8484d

Browse files
authored
Add missing get_transaction from async session (#186)
* Add missing get_transaction from async session Fixes: #185 * also add get_nested_transcation
1 parent 7034a97 commit 7f8484d

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

sqlalchemy-stubs/ext/asyncio/session.pyi

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,8 @@ class AsyncSession(
244244
async def __aexit__(
245245
self, type_: Any, value: Any, traceback: Any
246246
) -> None: ...
247+
def get_transaction(self) -> Optional[AsyncSessionTransaction]: ...
248+
def get_nested_transaction(self) -> Optional[AsyncSessionTransaction]: ...
247249

248250
class _AsyncSessionContextManager:
249251
async_session: AsyncSession = ...

test/files/async_stuff.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,10 @@ async def go() -> None:
2929
cr.first()
3030
scr = await conn.stream_scalars(text("select 1"))
3131
await scr.all()
32+
33+
ast = async_session.get_transaction()
34+
if ast:
35+
ast.is_active
36+
nt = async_session.get_nested_transaction()
37+
if nt:
38+
nt.is_active

0 commit comments

Comments
 (0)