From bb6f842d68af3ff57d3676229627944376381343 Mon Sep 17 00:00:00 2001 From: syokensyo Date: Thu, 21 Sep 2023 14:19:37 +0800 Subject: [PATCH] add support for absolute sqlite db path in case of using tauri dialog api --- plugins/sql/src/plugin.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/plugins/sql/src/plugin.rs b/plugins/sql/src/plugin.rs index 179b45ff..c3623a39 100644 --- a/plugins/sql/src/plugin.rs +++ b/plugins/sql/src/plugin.rs @@ -73,6 +73,18 @@ fn app_path(app: &AppHandle) -> PathBuf { /// Maps the user supplied DB connection string to a connection string /// with a fully qualified file path to the App's designed "app_path" fn path_mapper(mut app_path: PathBuf, connection_string: &str) -> String { + if connection_string.contains(std::path::MAIN_SEPARATOR_STR) { + let file_path = std::path::Path::new(connection_string); + if file_path.exists() { + format!( + "sqlite:{}", + connection_string + .split_once(':') + .expect("Couldn't parse the connection string for DB!") + .1 + ) + }; + } app_path.push( connection_string .split_once(':')