diff --git a/src-tauri/src/engines/sqlite.rs b/src-tauri/src/engines/sqlite.rs index c4440ef..b71aab9 100644 --- a/src-tauri/src/engines/sqlite.rs +++ b/src-tauri/src/engines/sqlite.rs @@ -1,8 +1,8 @@ use tauri::AppHandle; use crate::db::{ - build_sqlite_pool, get_or_create_sqlite_pool, quote_identifier, - require_safe_identifier, AppState, + build_sqlite_pool, get_or_create_sqlite_pool, is_safe_identifier, + quote_identifier, require_safe_identifier, AppState, }; use crate::error::VeloxError; use crate::models::{ColumnInfo, ConnectionInput, DatabaseInfo, QueryResult, TableInfo}; @@ -76,7 +76,10 @@ impl DatabaseEngineOps for SqliteEngine { for row in rows { let name: String = sqlite_get_idx(&row, 0, "name", "get_tables") .map_err(VeloxError::from)?; - require_safe_identifier(&name, "table name")?; + if !is_safe_identifier(&name) { + log::warn!("Skipping table with unsafe identifier: {:?}", name); + continue; + } tables.push(TableInfo { schema: "main".to_string(), preview_query: format!("select * from \"{}\" limit 100;", quote_identifier(&name)), diff --git a/src/features/connections/components/ConnectionDialog.tsx b/src/features/connections/components/ConnectionDialog.tsx index dd21c27..38f7bc3 100644 --- a/src/features/connections/components/ConnectionDialog.tsx +++ b/src/features/connections/components/ConnectionDialog.tsx @@ -72,7 +72,7 @@ const connectionSchema = z.object({ name: z.string().min(2, 'Enter a connection name.'), engine: z.enum(['postgres', 'mysql', 'sqlite', 'mongo', 'duckdb', 'redis'] as const), host: z.string(), - port: z.coerce.number().int().min(1).max(65535), + port: z.coerce.number().int().min(0).max(65535), database: z.string(), filePath: z.string().optional(), user: z.string(), diff --git a/src/features/connections/components/ConnectionsSidebarTree.tsx b/src/features/connections/components/ConnectionsSidebarTree.tsx index 7f11297..3f2c615 100644 --- a/src/features/connections/components/ConnectionsSidebarTree.tsx +++ b/src/features/connections/components/ConnectionsSidebarTree.tsx @@ -61,6 +61,11 @@ export function resolveExpandedDatabaseName( return dbList[0].name } } + if (connection.engine === 'sqlite' || connection.engine === 'duckdb') { + if (dbList.length > 0) { + return dbList[0].name + } + } return saved }