From 65114c64c4f61a7baf20a3a154c61f9d10bb86fd Mon Sep 17 00:00:00 2001 From: t8y2 <1156263951@qq.com> Date: Tue, 16 Jun 2026 20:30:21 +0800 Subject: [PATCH] fix(sqlite): support .db3 file extension --- apps/desktop/src/App.vue | 2 +- .../desktop/src/components/connection/ConnectionDialog.vue | 4 ++-- apps/desktop/src/composables/useFileDrop.ts | 2 +- src-tauri/src/commands/external_db.rs | 7 ++++--- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/apps/desktop/src/App.vue b/apps/desktop/src/App.vue index 008662326b..8cc6323d9f 100644 --- a/apps/desktop/src/App.vue +++ b/apps/desktop/src/App.vue @@ -592,7 +592,7 @@ async function openPendingSqlFiles() { } } -const DB_EXTENSIONS = [".db", ".sqlite", ".sqlite3", ".duckdb"]; +const DB_EXTENSIONS = [".db", ".db3", ".sqlite", ".sqlite3", ".duckdb"]; function getDbTypeFromPath(path: string): "sqlite" | "duckdb" | null { const lower = path.toLowerCase(); diff --git a/apps/desktop/src/components/connection/ConnectionDialog.vue b/apps/desktop/src/components/connection/ConnectionDialog.vue index e2939582da..9a7234c9dc 100644 --- a/apps/desktop/src/components/connection/ConnectionDialog.vue +++ b/apps/desktop/src/components/connection/ConnectionDialog.vue @@ -2001,7 +2001,7 @@ async function createDuckDbFilePath() { } function ensureSqliteFileExtension(path: string): string { - return /\.(db|sqlite|sqlite3)$/i.test(path) ? path : `${path}.db`; + return /\.(db|db3|sqlite|sqlite3)$/i.test(path) ? path : `${path}.db`; } async function createSqliteFilePath() { @@ -2010,7 +2010,7 @@ async function createSqliteFilePath() { const selected = await save({ title: t("connection.createSqliteFile"), defaultPath: "database.db", - filters: [{ name: "SQLite", extensions: ["db", "sqlite", "sqlite3"] }], + filters: [{ name: "SQLite", extensions: ["db", "db3", "sqlite", "sqlite3"] }], }); if (!selected) return; diff --git a/apps/desktop/src/composables/useFileDrop.ts b/apps/desktop/src/composables/useFileDrop.ts index 3765d25898..77d9ab73e0 100644 --- a/apps/desktop/src/composables/useFileDrop.ts +++ b/apps/desktop/src/composables/useFileDrop.ts @@ -7,7 +7,7 @@ import { useToast } from "@/composables/useToast"; import * as api from "@/lib/api"; import type { ConnectionConfig } from "@/types/database"; -const DB_EXTENSIONS = [".db", ".sqlite", ".sqlite3", ".duckdb"]; +const DB_EXTENSIONS = [".db", ".db3", ".sqlite", ".sqlite3", ".duckdb"]; function getDbType(path: string): "sqlite" | "duckdb" | null { const lower = path.toLowerCase(); diff --git a/src-tauri/src/commands/external_db.rs b/src-tauri/src/commands/external_db.rs index 8808b61212..ca5b65080e 100644 --- a/src-tauri/src/commands/external_db.rs +++ b/src-tauri/src/commands/external_db.rs @@ -1,7 +1,7 @@ use std::path::{Path, PathBuf}; use std::sync::Mutex; -const DB_EXTENSIONS: &[&str] = &["db", "sqlite", "sqlite3", "duckdb"]; +const DB_EXTENSIONS: &[&str] = &["db", "db3", "sqlite", "sqlite3", "duckdb"]; #[derive(Default)] pub struct ExternalDbOpenState { @@ -77,11 +77,11 @@ mod tests { #[test] fn filters_db_file_args_case_insensitively() { let paths = db_file_paths_from_args( - ["/tmp/a.db", "--flag", "/tmp/b.SQLITE", "/tmp/c.sqlite3", "/tmp/d.duckdb", "/tmp/e.txt"], + ["/tmp/a.db", "--flag", "/tmp/b.SQLITE", "/tmp/c.sqlite3", "/tmp/d.duckdb", "/tmp/e.db3", "/tmp/f.txt"], Path::new("/work"), ); - assert_eq!(paths, vec!["/tmp/a.db", "/tmp/b.SQLITE", "/tmp/c.sqlite3", "/tmp/d.duckdb"]); + assert_eq!(paths, vec!["/tmp/a.db", "/tmp/b.SQLITE", "/tmp/c.sqlite3", "/tmp/d.duckdb", "/tmp/e.db3"]); } #[test] @@ -103,6 +103,7 @@ mod tests { #[test] fn is_db_file_path_recognizes_extensions() { assert!(is_db_file_path(Path::new("test.db"))); + assert!(is_db_file_path(Path::new("test.db3"))); assert!(is_db_file_path(Path::new("test.sqlite"))); assert!(is_db_file_path(Path::new("test.sqlite3"))); assert!(is_db_file_path(Path::new("test.duckdb")));