diff --git a/src-web/src/main.rs b/src-web/src/main.rs index 6d77dadaa..54630b9b6 100644 --- a/src-web/src/main.rs +++ b/src-web/src/main.rs @@ -83,6 +83,7 @@ async fn main() { .route("/query/execute", post(routes::query::execute_query)) .route("/query/execute-multi", post(routes::query::execute_multi)) .route("/query/execute-batch", post(routes::query::execute_batch)) + .route("/query/execute-script", post(routes::query::execute_script)) .route("/query/cancel", post(routes::query::cancel_query)) // Redis .route("/redis/list-databases", post(routes::redis::list_databases)) diff --git a/src-web/src/routes/query.rs b/src-web/src/routes/query.rs index a3354272b..277dcfb8b 100644 --- a/src-web/src/routes/query.rs +++ b/src-web/src/routes/query.rs @@ -103,3 +103,20 @@ pub async fn cancel_query( let cancelled = state.app.running_queries.cancel(&req.execution_id); Json(serde_json::json!({ "cancelled": cancelled })) } + +pub async fn execute_script( + State(state): State>, + Json(req): Json, +) -> Result, AppError> { + let statements = dbx_core::sql::split_sql_statements(&req.sql); + let result = dbx_core::query::execute_statements( + &state.app, + &req.connection_id, + &req.database, + &statements, + ) + .await + .map_err(AppError)?; + + Ok(Json(serde_json::to_value(result).map_err(|e| AppError(e.to_string()))?)) +} diff --git a/src/App.vue b/src/App.vue index 26a002555..9a669e01d 100644 --- a/src/App.vue +++ b/src/App.vue @@ -942,7 +942,7 @@ const downloadProgress = ref(0); const updateReady = ref(false); async function downloadAndInstallUpdate() { - if (isDownloadingUpdate.value) return; + if (!isTauriRuntime() || isDownloadingUpdate.value) return; isDownloadingUpdate.value = true; downloadProgress.value = 0; try { @@ -970,6 +970,7 @@ async function downloadAndInstallUpdate() { } async function restartApp() { + if (!isTauriRuntime()) return; const { relaunch } = await import("@tauri-apps/plugin-process"); await relaunch(); }