From c0fdc222fbc02a518b551e73cb3f10d21ff54270 Mon Sep 17 00:00:00 2001 From: Nickiel12 Date: Sat, 17 Dec 2022 23:48:18 -0800 Subject: [PATCH] feat: now ignores primary key attempted insert --- src/db_operations.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/db_operations.rs b/src/db_operations.rs index 3726ee1..c60dcb9 100644 --- a/src/db_operations.rs +++ b/src/db_operations.rs @@ -11,8 +11,8 @@ pub enum DatabaseCreationError { } pub struct DatabaseRequest { - search_type: SearchType, - search_tag: PartialTag, + pub search_type: SearchType, + pub search_tag: PartialTag, } pub enum SearchType { @@ -21,11 +21,11 @@ pub enum SearchType { } pub struct PartialTag { - path: Option, - title: Option, - artist: Option, - album: Option, - album_artist: Option, + pub path: Option, + pub title: Option, + pub artist: Option, + pub album: Option, + pub album_artist: Option, } impl Default for PartialTag { @@ -147,7 +147,7 @@ impl DBObject { pub fn save_tag(self: &Self, tag: &ItemTag) -> Result<(), DatabaseCreationError> { self.conn.execute( - "INSERT INTO musicinfo (path, title, artist, album, album_artist) VALUES ( ?1, ?2, ?3, ?4, ?5 )", + "INSERT OR IGNORE INTO musicinfo (path, title, artist, album, album_artist) VALUES ( ?1, ?2, ?3, ?4, ?5 )", params![tag.path, tag.title, tag.artist, tag.album, tag.album_artist], )?; Ok(())