From ae545aed1f1c9b3705ee40701bcbd6233c0434ae Mon Sep 17 00:00:00 2001 From: Syfaro Date: Thu, 9 Jan 2020 00:12:06 -0600 Subject: [PATCH] Insert file_id when possible. --- src/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index d38d2a7..6111b4c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -73,7 +73,7 @@ fn insert_submission( let hash = sub.hash.clone(); let url = sub.content.url(); - client.execute("INSERT INTO submission (id, artist_id, url, filename, hash, rating, posted_at, description, hash_int) VALUES ($1, $2, $3, $4, decode($5, 'base64'), $6, $7, $8, $9)", &[ + client.execute("INSERT INTO submission (id, artist_id, url, filename, hash, rating, posted_at, description, hash_int, file_id) VALUES ($1, $2, $3, $4, decode($5, 'base64'), $6, $7, $8, $9, CASE WHEN isnumeric(split_part($4, '.', 1)) THEN split_part($4, '.', 1)::int ELSE null END)", &[ &sub.id, &artist_id, &url, &sub.filename, &hash, &sub.rating.serialize(), &sub.posted_at, &sub.description, &sub.hash_num, ])?;