Skip to content
Open
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
33 changes: 12 additions & 21 deletions src-tauri/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2683,17 +2683,15 @@ pub async fn delete_record<R: Runtime>(
app: AppHandle<R>,
connection_id: String,
table: String,
pk_col: String,
pk_val: serde_json::Value,
pk_map: std::collections::HashMap<String, serde_json::Value>,
schema: Option<String>,
database: Option<String>,
) -> Result<u64, String> {
log::info!(
"Executing query on connection: {} | Query: DELETE FROM {} WHERE {} = {}",
"Executing query on connection: {} | Query: DELETE FROM {} WHERE pk_map={:?}",
connection_id,
table,
pk_col,
pk_val
pk_map
);
let saved_conn = find_connection_by_id(&app, &connection_id)?;
let expanded_params = expand_ssh_connection_params(&app, &saved_conn.params).await?;
Expand All @@ -2703,7 +2701,7 @@ pub async fn delete_record<R: Runtime>(
params.database = crate::models::DatabaseSelection::Single(db);
}
let drv = driver_for(&saved_conn.params.driver).await?;
drv.delete_record(&params, &table, &pk_col, pk_val, schema.as_deref())
drv.delete_record(&params, &table, &pk_map, schema.as_deref())
.await
}

Expand All @@ -2712,21 +2710,19 @@ pub async fn update_record<R: Runtime>(
app: AppHandle<R>,
connection_id: String,
table: String,
pk_col: String,
pk_val: serde_json::Value,
pk_map: std::collections::HashMap<String, serde_json::Value>,
col_name: String,
new_val: serde_json::Value,
schema: Option<String>,
database: Option<String>,
) -> Result<u64, String> {
log::info!(
"Executing query on connection: {} | Query: UPDATE {} SET {} = {} WHERE {} = {}",
"Executing query on connection: {} | Query: UPDATE {} SET {} = {:?} WHERE pk_map={:?}",
connection_id,
table,
col_name,
new_val,
pk_col,
pk_val
pk_map
);
let saved_conn = find_connection_by_id(&app, &connection_id)?;
let expanded_params = expand_ssh_connection_params(&app, &saved_conn.params).await?;
Expand All @@ -2740,8 +2736,7 @@ pub async fn update_record<R: Runtime>(
drv.update_record(
&params,
&table,
&pk_col,
pk_val,
&pk_map,
&col_name,
new_val,
schema.as_deref(),
Expand All @@ -2756,8 +2751,7 @@ pub async fn save_blob_to_file<R: Runtime>(
connection_id: String,
table: String,
col_name: String,
pk_col: String,
pk_val: serde_json::Value,
pk_map: std::collections::HashMap<String, serde_json::Value>,
file_path: String,
schema: Option<String>,
) -> Result<(), String> {
Expand All @@ -2770,8 +2764,7 @@ pub async fn save_blob_to_file<R: Runtime>(
&params,
&table,
&col_name,
&pk_col,
pk_val,
&pk_map,
schema.as_deref(),
&file_path,
)
Expand All @@ -2786,8 +2779,7 @@ pub async fn fetch_blob_as_data_url<R: Runtime>(
connection_id: String,
table: String,
col_name: String,
pk_col: String,
pk_val: serde_json::Value,
pk_map: std::collections::HashMap<String, serde_json::Value>,
schema: Option<String>,
) -> Result<String, String> {
let saved_conn = find_connection_by_id(&app, &connection_id)?;
Expand All @@ -2800,8 +2792,7 @@ pub async fn fetch_blob_as_data_url<R: Runtime>(
&params,
&table,
&col_name,
&pk_col,
pk_val,
&pk_map,
schema.as_deref(),
)
.await?;
Expand Down
12 changes: 4 additions & 8 deletions src-tauri/src/drivers/driver_trait.rs
Original file line number Diff line number Diff line change
Expand Up @@ -435,8 +435,7 @@ pub trait DatabaseDriver: Send + Sync {
&self,
params: &ConnectionParams,
table: &str,
pk_col: &str,
pk_val: serde_json::Value,
pk_map: &std::collections::HashMap<String, serde_json::Value>,
col_name: &str,
new_val: serde_json::Value,
schema: Option<&str>,
Expand All @@ -447,8 +446,7 @@ pub trait DatabaseDriver: Send + Sync {
&self,
params: &ConnectionParams,
table: &str,
pk_col: &str,
pk_val: serde_json::Value,
pk_map: &std::collections::HashMap<String, serde_json::Value>,
schema: Option<&str>,
) -> Result<u64, String>;

Expand All @@ -459,8 +457,7 @@ pub trait DatabaseDriver: Send + Sync {
_params: &ConnectionParams,
_table: &str,
_col_name: &str,
_pk_col: &str,
_pk_val: serde_json::Value,
_pk_map: &std::collections::HashMap<String, serde_json::Value>,
_schema: Option<&str>,
_file_path: &str,
) -> Result<(), String> {
Expand All @@ -472,8 +469,7 @@ pub trait DatabaseDriver: Send + Sync {
_params: &ConnectionParams,
_table: &str,
_col_name: &str,
_pk_col: &str,
_pk_val: serde_json::Value,
_pk_map: &std::collections::HashMap<String, serde_json::Value>,
_schema: Option<&str>,
) -> Result<String, String> {
Err("BLOB preview not supported by this driver".into())
Expand Down
Loading