feat(sqlite): support custom database file suffixes
This commit is contained in:
1 parent
25bac0c67a
commit
49705a1a8f
10 files changed
+138
-31
No files matched your search
@@ -69,6 +69,7 @@ import { safeLocalStorageGet, safeLocalStorageSet } from "@/lib/safeStorage";
|
||||
import { rankSavedSqlHistory } from "@/lib/savedSqlHistory";
|
||||
import { isSchemaAware, isSingleDatabase, usesTreeSchemaMode } from "@/lib/databaseFeatureSupport";
|
||||
import { connectionUsesDatabaseObjectTreeMode, effectiveDatabaseTypeForConnection } from "@/lib/jdbcDialect";
|
||||
import { detectDatabaseFileType } from "@/lib/databaseFileDetection";
|
||||
import { Dialog, DialogContent, DialogFooter, DialogHeader, DialogTitle } from "@/components/ui/dialog";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Input } from "@/components/ui/input";
|
||||
@@ -624,21 +625,12 @@ async function openPendingSqlFiles() {
|
||||
}
|
||||
}
|
||||
|
||||
const DB_EXTENSIONS = [".db", ".db3", ".sqlite", ".sqlite3", ".duckdb"];
|
||||
|
||||
function getDbTypeFromPath(path: string): "sqlite" | "duckdb" | null {
|
||||
const lower = path.toLowerCase();
|
||||
if (lower.endsWith(".duckdb")) return "duckdb";
|
||||
if (DB_EXTENSIONS.some((ext) => lower.endsWith(ext))) return "sqlite";
|
||||
return null;
|
||||
}
|
||||
|
||||
async function openDbFilePath(path: string) {
|
||||
if (!isTauriRuntime()) return;
|
||||
await connectionStore.initFromDisk();
|
||||
try {
|
||||
const name = path.split("/").pop()?.split("\\").pop() || path;
|
||||
const dbType = getDbTypeFromPath(path);
|
||||
const dbType = await detectDatabaseFileType(path);
|
||||
if (!dbType) return;
|
||||
|
||||
// Check for existing connection with the same file path
|
||||
|
||||
Reference in new issue
Block a user