Fix when no reviews exist raises error

This commit is contained in:
Esa Kataja
2025-05-15 19:16:54 +03:00
parent e560809c25
commit 58632e29cb
+2 -2
View File
@@ -13,7 +13,7 @@ async def list_reviews():
with get_connection() as conn: with get_connection() as conn:
reviews = conn.execute("SELECT * FROM Review").fetchdf() reviews = conn.execute("SELECT * FROM Review").fetchdf()
if reviews.empty: if reviews.empty:
raise HTTPException(status_code=404, detail="Reviews not found") return []
return reviews.to_dict(orient="records") return reviews.to_dict(orient="records")
@@ -25,7 +25,7 @@ async def get_review(song_id: int, user_id: int):
(song_id, user_id), (song_id, user_id),
).fetchdf() ).fetchdf()
if review.empty: if review.empty:
raise HTTPException(status_code=404, detail="Review not found") return []
return review.to_dict(orient="records")[0] return review.to_dict(orient="records")[0]