mirror of
https://github.com/grillazz/fastapi-sqlalchemy-asyncpg.git
synced 2025-08-26 16:40:40 +03:00
fix
This commit is contained in:
parent
700a2d49a6
commit
7d122f7062
@ -84,7 +84,7 @@ async def find_stuff_pool(
|
|||||||
HTTPException: If the 'Stuff' object is not found or an SQLAlchemyError occurs.
|
HTTPException: If the 'Stuff' object is not found or an SQLAlchemyError occurs.
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
stmt = await Stuff.find(db_session, name, compile_sql=True)
|
stmt = await Stuff.get_by_name(db_session, name, compile_sql=True)
|
||||||
result = await request.app.postgres_pool.fetchrow(str(stmt))
|
result = await request.app.postgres_pool.fetchrow(str(stmt))
|
||||||
except SQLAlchemyError as ex:
|
except SQLAlchemyError as ex:
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
@ -100,7 +100,7 @@ async def find_stuff_pool(
|
|||||||
|
|
||||||
@router.delete("/{name}")
|
@router.delete("/{name}")
|
||||||
async def delete_stuff(name: str, db_session: AsyncSession = Depends(get_db)):
|
async def delete_stuff(name: str, db_session: AsyncSession = Depends(get_db)):
|
||||||
stuff = await Stuff.find(db_session, name)
|
stuff = await Stuff.get_by_name(db_session, name)
|
||||||
return await Stuff.delete(stuff, db_session)
|
return await Stuff.delete(stuff, db_session)
|
||||||
|
|
||||||
|
|
||||||
@ -110,6 +110,6 @@ async def update_stuff(
|
|||||||
name: str,
|
name: str,
|
||||||
db_session: AsyncSession = Depends(get_db),
|
db_session: AsyncSession = Depends(get_db),
|
||||||
):
|
):
|
||||||
stuff = await Stuff.find(db_session, name)
|
stuff = await Stuff.get_by_name(db_session, name)
|
||||||
await stuff.update(**payload.model_dump())
|
await stuff.update(**payload.model_dump())
|
||||||
return stuff
|
return stuff
|
||||||
|
Loading…
x
Reference in New Issue
Block a user