From: Daniel Sam Date: Fri, 6 Feb 2026 09:15:02 +0000 (+0530) Subject: 📝 Fix async example in `session.execute()` docstring & deprecation message (#1643) X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=edcaa54927af8d6ecc66a0d97d60e0cb785a6e7a;p=thirdparty%2Ffastapi%2Fsqlmodel.git 📝 Fix async example in `session.execute()` docstring & deprecation message (#1643) Fix async example in session.execute() deprecation warning & docstring Co-authored-by: Motov Yurii <109919500+YuriiMotov@users.noreply.github.com> --- diff --git a/sqlmodel/ext/asyncio/session.py b/sqlmodel/ext/asyncio/session.py index 056737f8..11e99ed8 100644 --- a/sqlmodel/ext/asyncio/session.py +++ b/sqlmodel/ext/asyncio/session.py @@ -116,13 +116,15 @@ class AsyncSession(_AsyncSession): 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() ``` """ ) @@ -145,13 +147,15 @@ class AsyncSession(_AsyncSession): 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(