From 058df10590fd6dee99020a41e0f43bf18767375b Mon Sep 17 00:00:00 2001 From: w33d Date: Mon, 3 Mar 2025 20:26:13 +0800 Subject: [PATCH] feat(sql): improved sqlite load path --- plugins/sql/guest-js/index.ts | 10 ++-------- plugins/sql/src/wrapper.rs | 3 +-- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/plugins/sql/guest-js/index.ts b/plugins/sql/guest-js/index.ts index 2f6c53e9..2fdece6a 100644 --- a/plugins/sql/guest-js/index.ts +++ b/plugins/sql/guest-js/index.ts @@ -68,17 +68,11 @@ export default class Database { * * # Sqlite * - * The path is relative to `tauri::path::BaseDirectory::App` by default and must start with `sqlite:`. + * The path is relative to `tauri::path::BaseDirectory::App` and must start with `sqlite:`. * * @example * ```ts - * // for relative path - * const db = await Database.get("sqlite:test.db"); - * ``` - * @example - * ```ts - * // for absolute path - * const db = await Database.get("sqlite:/home/ubuntu/test.db"); + * const db = Database.get("sqlite:test.db"); * ``` */ static get(path: string): Database { diff --git a/plugins/sql/src/wrapper.rs b/plugins/sql/src/wrapper.rs index 714c66f5..f522fc94 100644 --- a/plugins/sql/src/wrapper.rs +++ b/plugins/sql/src/wrapper.rs @@ -4,7 +4,6 @@ #[cfg(feature = "sqlite")] use std::fs::create_dir_all; -use std::path::Path; use indexmap::IndexMap; use serde_json::Value as JsonValue; @@ -77,7 +76,7 @@ impl DbPool { { #[cfg(feature = "sqlite")] "sqlite" => { - let conn_url = if Path::new(conn_url).is_absolute() { + let conn_url = if std::path::Path::new(conn_url).is_absolute() { create_dir_all(conn_url).expect("Couldn't create dir"); conn_url