From 4c684fbec88a3f16a12b6de2f5011089e9d80072 Mon Sep 17 00:00:00 2001 From: erikmf123 Date: Thu, 5 Mar 2026 20:42:20 +0000 Subject: [PATCH] fixat lite --- routes/song_router.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/routes/song_router.py b/routes/song_router.py index 87c730f2..54a08707 100644 --- a/routes/song_router.py +++ b/routes/song_router.py @@ -60,6 +60,10 @@ def update_song(song_id: int, song_data: SongCreate, db: DB_dependency): if song is None: raise HTTPException(status.HTTP_404_NOT_FOUND) + # simply check if the title is being changed to an already existing title, if so, throw an error. Copied from create_song + num_existing = db.query(Song_DB).filter(Song_DB.title == song_data.title).count() + if num_existing > 0: + raise HTTPException(status.HTTP_400_BAD_REQUEST, detail="Ths post already exists") # This does not allow one to "unset" values that could be null but aren't currently for var, value in vars(song_data).items(): setattr(song, var, value) if value else None