From 42971f7b1ae7fb006a1a2007db72a8c45e45fd36 Mon Sep 17 00:00:00 2001 From: Benedikt Peetz Date: Thu, 22 Aug 2024 20:25:30 +0200 Subject: fix(storage/setters): Avoid writing a literal "NULL" string into the db Sqlx supports turning an option to a NULL insertion, but trying to insert a string, containing "NULL", will result in this literal string being written to the database. --- src/storage/video_database/setters.rs | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) (limited to 'src/storage') diff --git a/src/storage/video_database/setters.rs b/src/storage/video_database/setters.rs index ec5a5e1..42875ce 100644 --- a/src/storage/video_database/setters.rs +++ b/src/storage/video_database/setters.rs @@ -204,17 +204,9 @@ pub async fn set_video_options( } pub async fn add_video(app: &App, video: Video) -> Result<()> { - let parent_subscription_name = if let Some(subs) = video.parent_subscription_name { - subs - } else { - "NULL".to_owned() - }; + let parent_subscription_name = video.parent_subscription_name; - let thumbnail_url = if let Some(thum) = video.thumbnail_url { - thum.to_string() - } else { - "NULL".to_owned() - }; + let thumbnail_url = video.thumbnail_url.map(|val| val.to_string()); let status = video.status.as_db_integer(); let status_change = if video.status_change { 1 } else { 0 }; -- cgit 1.4.1