From dccd01b2c34bb25176af2422e22bc06cd1f97f7d Mon Sep 17 00:00:00 2001 From: Daniel S A Date: Tue, 11 Nov 2025 21:23:01 +0530 Subject: [PATCH] Fix async example in session.execute() deprecation warning & docstring --- sqlmodel/ext/asyncio/session.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/sqlmodel/ext/asyncio/session.py b/sqlmodel/ext/asyncio/session.py index ff99dff899..55b679d6ac 100644 --- a/sqlmodel/ext/asyncio/session.py +++ b/sqlmodel/ext/asyncio/session.py @@ -119,13 +119,15 @@ async def exec( For example: ```Python - heroes = await session.execute(select(Hero)).scalars().all() + result = await session.execute(select(Hero)) + heroes = result.scalars().all() ``` instead you could use `exec()`: ```Python - heroes = await session.exec(select(Hero)).all() + result = await session.exec(select(Hero)) + heroes = result.all() ``` """ ) @@ -148,13 +150,15 @@ async def execute( For example: ```Python - heroes = await session.execute(select(Hero)).scalars().all() + result = await session.execute(select(Hero)) + heroes = result.scalars().all() ``` instead you could use `exec()`: ```Python - heroes = await session.exec(select(Hero)).all() + result = await session.exec(select(Hero)) + heroes = result.all() ``` """ return await super().execute(