diff options
author | niliara-edu <nil.jimeno@estudiant.fjaverianas.com> | 2025-01-26 12:25:13 +0100 |
---|---|---|
committer | niliara-edu <nil.jimeno@estudiant.fjaverianas.com> | 2025-01-26 12:25:13 +0100 |
commit | 5898e5ab4359945ef52dc7460bb2937a85603fc2 (patch) | |
tree | 0ef4c760bd6e30df2897e9cc725552ef54e51983 /src/database/song.rs | |
parent | e3f0f700bf2de3b8e7d7c72893a4d6cb128f000d (diff) |
authentication done
Diffstat (limited to 'src/database/song.rs')
-rw-r--r-- | src/database/song.rs | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/database/song.rs b/src/database/song.rs index 45c217b..95b05ba 100644 --- a/src/database/song.rs +++ b/src/database/song.rs @@ -140,18 +140,22 @@ impl DatabaseWrapper { } pub async fn edit_song(&self, data: SongPut) -> Result<MySqlQueryResult, sqlx::Error> { - if data.id.is_none() { return Err(sqlx::Error::RowNotFound); } + if data.id.is_none() { + return Err(sqlx::Error::RowNotFound); + } let og_song: Song = match self.select_song_by_id(data.id.as_ref().unwrap()).await { Ok(res) => match res.is_some() { true => res.unwrap(), false => return Err(sqlx::Error::RowNotFound), - } + }, Err(_) => return Err(sqlx::Error::RowNotFound), }; sqlx::query!( "UPDATE song SET name=?, lyrics=? WHERE id=?", - data.name.unwrap_or(og_song.name.unwrap_or(String::default())), - data.lyrics.unwrap_or(og_song.lyrics.unwrap_or(String::default())), + data.name + .unwrap_or(og_song.name.unwrap_or(String::default())), + data.lyrics + .unwrap_or(og_song.lyrics.unwrap_or(String::default())), data.id, ) .execute(&self.db_pool) |