- add decorator to compile sql for pool or return scalar from statement

This commit is contained in:
Jakub Miazek
2024-05-11 16:29:00 +02:00
parent e003454647
commit c8efc0596c
2 changed files with 21 additions and 7 deletions

View File

@@ -45,7 +45,10 @@ async def create_stuff(
async def find_stuff(name: str, db_session: AsyncSession = Depends(get_db)):
result = await Stuff.find(db_session, name)
if not result:
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail=f"Stuff with name {name} not found.")
raise HTTPException(
status_code=status.HTTP_404_NOT_FOUND,
detail=f"Stuff with name {name} not found.",
)
return result
@@ -91,7 +94,6 @@ async def find_stuff_pool(
return result
@router.delete("/{name}")
async def delete_stuff(name: str, db_session: AsyncSession = Depends(get_db)):
stuff = await Stuff.find(db_session, name)