about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorBenedikt Peetz <benedikt.peetz@b-peetz.de>2024-08-22 20:25:30 +0200
committerBenedikt Peetz <benedikt.peetz@b-peetz.de>2024-08-22 20:25:30 +0200
commit42971f7b1ae7fb006a1a2007db72a8c45e45fd36 (patch)
tree95e940b460557197f91d5b354e7f945358e56413
parentrefactor(storage): Make all URL parsings panic (diff)
downloadyt-42971f7b1ae7fb006a1a2007db72a8c45e45fd36.tar.gz
yt-42971f7b1ae7fb006a1a2007db72a8c45e45fd36.zip
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.
-rw-r--r--src/storage/video_database/setters.rs12
1 files changed, 2 insertions, 10 deletions
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 };