diff --git a/oca/src/facade/fetch.rs b/oca/src/facade/fetch.rs index 68139ff..854e55b 100644 --- a/oca/src/facade/fetch.rs +++ b/oca/src/facade/fetch.rs @@ -12,10 +12,10 @@ use oca_bundle::state::oca::{capture_base::CaptureBase, DynOverlay, OCABundle}; use said::SelfAddressingIdentifier; use serde::Serialize; +use std::borrow::Borrow; #[cfg(feature = "local-references")] use std::collections::HashMap; use std::str::FromStr; -use std::borrow::Borrow; #[derive(Debug, Serialize)] #[serde(untagged)] diff --git a/oca/src/facade/mod.rs b/oca/src/facade/mod.rs index 2a8fcd5..88c00bd 100644 --- a/oca/src/facade/mod.rs +++ b/oca/src/facade/mod.rs @@ -11,19 +11,23 @@ mod fetch; #[derive(Clone)] pub struct Connection { - pub connection: Arc> + pub connection: Arc>, } impl Connection { pub fn new(path: &str) -> Self { let conn = rusqlite::Connection::open(path).unwrap(); - Self {connection: Arc::new(Mutex::new(conn))} + Self { + connection: Arc::new(Mutex::new(conn)), + } } - pub fn execute

(&self, sql: &str, params: P) where P: Params { + pub fn execute

(&self, sql: &str, params: P) -> rusqlite::Result + where + P: Params, + { let connection = self.connection.lock().unwrap(); - connection.execute(sql, params).unwrap(); - + connection.execute(sql, params) } } diff --git a/oca/src/repositories/capture_base_cache_repo.rs b/oca/src/repositories/capture_base_cache_repo.rs index 0db5618..33ae5f9 100644 --- a/oca/src/repositories/capture_base_cache_repo.rs +++ b/oca/src/repositories/capture_base_cache_repo.rs @@ -34,11 +34,9 @@ impl CaptureBaseCacheRepo { said TEXT PRIMARY KEY, capture_base TEXT )"#; - connection.execute(create_table_query, ()); + let _ = connection.execute(create_table_query, ()); - Self { - connection, - } + Self { connection } } pub fn insert(&self, model: CaptureBaseCacheRecord) { @@ -68,7 +66,7 @@ impl CaptureBaseCacheRepo { ) AS results ON true GROUP BY said"; - + let connection = self.connection.connection.lock().unwrap(); let mut statement = connection.prepare(query).unwrap(); diff --git a/oca/src/repositories/oca_bundle_cache_repo.rs b/oca/src/repositories/oca_bundle_cache_repo.rs index e88508b..342c672 100644 --- a/oca/src/repositories/oca_bundle_cache_repo.rs +++ b/oca/src/repositories/oca_bundle_cache_repo.rs @@ -34,11 +34,9 @@ impl OCABundleCacheRepo { said TEXT PRIMARY KEY, oca_bundle TEXT )"#; - connection.execute(create_table_query, ()); + connection.execute(create_table_query, ()).unwrap(); - Self { - connection, - } + Self { connection } } pub fn insert(&self, model: OCABundleCacheRecord) { @@ -68,7 +66,7 @@ impl OCABundleCacheRepo { ) AS results ON true GROUP BY said"; - + let connection = self.connection.connection.lock().unwrap(); let mut statement = connection.prepare(query).unwrap(); let models = statement diff --git a/oca/src/repositories/oca_bundle_fts_repo.rs b/oca/src/repositories/oca_bundle_fts_repo.rs index 2fc20cc..7d63b15 100644 --- a/oca/src/repositories/oca_bundle_fts_repo.rs +++ b/oca/src/repositories/oca_bundle_fts_repo.rs @@ -43,11 +43,9 @@ impl OCABundleFTSRepo { oca_bundle_said UNINDEXED, tokenize="trigram" )"#; - connection.execute(create_table_query, ()); + connection.execute(create_table_query, ()).unwrap(); - Self { - connection, - } + Self { connection } } pub fn insert(&self, model: OCABundleFTSRecord) { @@ -166,7 +164,6 @@ meta_overlay:{} } } - let connection = self.connection.connection.lock().unwrap(); let mut statement = connection.prepare(sql_query).unwrap();