]> git.ipfire.org Git - thirdparty/fastapi/sqlmodel.git/commitdiff
📝 Fix async example in `session.execute()` docstring & deprecation message (#1643)
authorDaniel Sam <daniellevilucas@gmail.com>
Fri, 6 Feb 2026 09:15:02 +0000 (14:45 +0530)
committerGitHub <noreply@github.com>
Fri, 6 Feb 2026 09:15:02 +0000 (10:15 +0100)
Fix async example in session.execute() deprecation warning & docstring

Co-authored-by: Motov Yurii <109919500+YuriiMotov@users.noreply.github.com>
sqlmodel/ext/asyncio/session.py

index 056737f866cd343cd8744c6b0c250d326675617f..11e99ed86086872103ced28fec4080d58c2f0d33 100644 (file)
@@ -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(