From eb1afb1c3a7378ec9cbe237dc04e4a74c16d8d7a Mon Sep 17 00:00:00 2001 From: "Kholmatov B." <21.sfrvn@gmail.com> Date: Wed, 16 Oct 2024 00:53:30 +0500 Subject: [PATCH] fix: scalar_one_or_none in detail --- fastapi_sqlalchemy_toolkit/model_manager.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/fastapi_sqlalchemy_toolkit/model_manager.py b/fastapi_sqlalchemy_toolkit/model_manager.py index 422426f..a3d60bd 100644 --- a/fastapi_sqlalchemy_toolkit/model_manager.py +++ b/fastapi_sqlalchemy_toolkit/model_manager.py @@ -243,7 +243,9 @@ async def get( result = await session.execute(stmt) if base_stmt is None: - return result.scalars().first() + if order_by is not None: + return result.scalars().first() + return result.scalar_one_or_none() return result.first() async def get_or_404(