From 44f531ecf9d1551817e5172c015f1bbc592c7df1 Mon Sep 17 00:00:00 2001 From: mdecimus Date: Sun, 7 Apr 2024 17:39:58 +0200 Subject: [PATCH] Fixed compile without SQL dbs --- crates/store/src/config.rs | 5 +---- crates/store/src/dispatch/lookup.rs | 7 +++++++ crates/store/src/lib.rs | 12 ++++++++++++ 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/crates/store/src/config.rs b/crates/store/src/config.rs index cef9511d..d84d3f54 100644 --- a/crates/store/src/config.rs +++ b/crates/store/src/config.rs @@ -234,10 +234,7 @@ impl Stores { // Add SQL queries as lookup stores for (store_id, lookup_store) in self.stores.iter().filter_map(|(id, store)| { - if matches!( - store, - Store::MySQL(_) | Store::PostgreSQL(_) | Store::SQLite(_) - ) { + if store.is_sql() { Some((id.clone(), LookupStore::from(store.clone()))) } else { None diff --git a/crates/store/src/dispatch/lookup.rs b/crates/store/src/dispatch/lookup.rs index f7a88b90..21c4d989 100644 --- a/crates/store/src/dispatch/lookup.rs +++ b/crates/store/src/dispatch/lookup.rs @@ -352,6 +352,13 @@ impl LookupStore { Ok(()) } + + pub fn is_sql(&self) -> bool { + match self { + LookupStore::Store(store) => store.is_sql(), + _ => false, + } + } } enum LookupValue { diff --git a/crates/store/src/lib.rs b/crates/store/src/lib.rs index a777b32e..eeb20259 100644 --- a/crates/store/src/lib.rs +++ b/crates/store/src/lib.rs @@ -677,6 +677,18 @@ impl Store { pub fn is_none(&self) -> bool { matches!(self, Self::None) } + + pub fn is_sql(&self) -> bool { + match self { + #[cfg(feature = "sqlite")] + Store::SQLite(_) => true, + #[cfg(feature = "postgres")] + Store::PostgreSQL(_) => true, + #[cfg(feature = "mysql")] + Store::MySQL(_) => true, + _ => false, + } + } } impl std::fmt::Debug for Store {