fix: 修剩余的 (await ...)).scalar_one_or_none() 链式 + bookmark
This commit is contained in:
@@ -21,7 +21,8 @@ async def add(
|
||||
user: User = Depends(get_current_user),
|
||||
session: AsyncSession = Depends(get_session),
|
||||
):
|
||||
art = (await session.execute(select(Article).where(Article.id == body.article_id))).scalar_one_or_none()
|
||||
result = await session.execute(select(Article).where(Article.id == body.article_id))
|
||||
art = result.scalar_one_or_none()
|
||||
if not art:
|
||||
raise HTTPException(status.HTTP_404_NOT_FOUND, "Article not found")
|
||||
# 已存在则直接返回
|
||||
|
||||
Reference in New Issue
Block a user