From 99b48ba42ba49283693029097f38b68022a6e625 Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Thu, 9 Mar 2023 19:09:55 +0100 Subject: [PATCH] Fixes --- schemsearch-cli/src/main.rs | 3 ++- schemsearch-lib/src/lib.rs | 1 + schemsearch-sql/src/filter.rs | 2 +- schemsearch-sql/src/lib.rs | 4 ++++ 4 files changed, 8 insertions(+), 2 deletions(-) diff --git a/schemsearch-cli/src/main.rs b/schemsearch-cli/src/main.rs index 98f2e2b..c2ad913 100644 --- a/schemsearch-cli/src/main.rs +++ b/schemsearch-cli/src/main.rs @@ -182,6 +182,7 @@ fn main() { })) }; } + if schematics.is_empty() { cmd.error(ErrorKind::MissingRequiredArgument, "No schematics specified").exit(); } @@ -239,7 +240,7 @@ fn main() { search_schempath(search_behavior, &pattern, &mut output_std, &mut output_std_csv, &mut output_file_csv, &mut output_file, &mut lock, &mut file_out, schematic, x.path().file_name().unwrap().to_str().unwrap().to_string()); } } - Err(e) => cmd.error(ErrorKind::Io, format!("Error while reading dir: {}", e.to_string())).exit() + Err(e) => cmd.error(ErrorKind::Io, format!("Error while reading schem: {}", e.to_string())).exit() } } } diff --git a/schemsearch-lib/src/lib.rs b/schemsearch-lib/src/lib.rs index 9f1503f..5d14c59 100644 --- a/schemsearch-lib/src/lib.rs +++ b/schemsearch-lib/src/lib.rs @@ -107,6 +107,7 @@ pub fn parse_schematic(data: &Vec) -> Schematic { } #[allow(unused_imports)] +#[cfg(test)] mod tests { use std::path::Path; use schemsearch_files::Schematic; diff --git a/schemsearch-sql/src/filter.rs b/schemsearch-sql/src/filter.rs index 7c65e50..3114a00 100644 --- a/schemsearch-sql/src/filter.rs +++ b/schemsearch-sql/src/filter.rs @@ -25,7 +25,7 @@ impl SchematicFilter { pub fn build(self) -> String { let mut query = Vec::new(); if let Some(user_id) = self.user_id { - query.push(user_id.into_iter().map(|id| format!("ND.NodeOwner = {}", id)).collect::>().join(" OR ")); + query.push(user_id.into_iter().map(|id| format!("SN.NodeOwner = {}", id)).collect::>().join(" OR ")); } if let Some(name) = self.name { query.push(name.into_iter().map(|name| format!("SN.NodeName LIKE '%{}%'", name)).collect::>().join(" OR ")); diff --git a/schemsearch-sql/src/lib.rs b/schemsearch-sql/src/lib.rs index a428e0e..e99f2e1 100644 --- a/schemsearch-sql/src/lib.rs +++ b/schemsearch-sql/src/lib.rs @@ -65,3 +65,7 @@ pub async fn load_schemdata(id: i32) -> Vec { rows.get(0) } +pub async fn close() { + unsafe { CONN.lock().unwrap().take().unwrap().close().await } +} +