Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions src-tauri/src/engines/sqlite.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand Down Expand Up @@ -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)),
Expand Down
2 changes: 1 addition & 1 deletion src/features/connections/components/ConnectionDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
Loading