From 92fe47b913600ea2ee52962979085203017d8151 Mon Sep 17 00:00:00 2001 From: t8y2 <1156263951@qq.com> Date: Fri, 8 May 2026 16:45:01 +0800 Subject: [PATCH] fix: pass SQL directly in AI execute to avoid stale state (#153) When executing SQL from the AI panel, pass the SQL string directly to tryExecute() instead of relying on the executableSql computed property, which could use stale selectedSql or cursorPos values. --- crates/dbx-core/src/db/oracle_driver.rs | 16 ++++++++++++++-- src/App.vue | 3 ++- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/crates/dbx-core/src/db/oracle_driver.rs b/crates/dbx-core/src/db/oracle_driver.rs index 1374f0e32a..83127bc900 100644 --- a/crates/dbx-core/src/db/oracle_driver.rs +++ b/crates/dbx-core/src/db/oracle_driver.rs @@ -17,10 +17,22 @@ pub async fn connect( ) -> Result { let mut config = Config::new(host, port, service, user, pass); config.sysdba = sysdba; - tokio::time::timeout(connection_timeout(), Connection::connect_with_config(config)) + let conn = tokio::time::timeout(connection_timeout(), Connection::connect_with_config(config)) .await .map_err(|_| format!("Oracle connection timed out ({CONNECTION_TIMEOUT_SECS}s)"))? - .map_err(|e| format!("Oracle connection failed: {e}")) + .map_err(|e| format!("Oracle connection failed: {e}"))?; + + // Verify connection works with a simple query + log::info!("[oracle] connect: verifying with SELECT 1 FROM DUAL..."); + conn.query("SELECT 1 FROM DUAL", &[]).await.map_err(|e| format!("Oracle connection verification failed: {e}"))?; + log::info!("[oracle] connect: verification OK, testing multi-row..."); + let r = conn + .query("SELECT username FROM all_users ORDER BY username", &[]) + .await + .map_err(|e| format!("Oracle multi-row test failed: {e}"))?; + log::info!("[oracle] connect: multi-row OK, {} rows", r.rows.len()); + + Ok(conn) } fn value_to_json(val: &rust_oracle::Value) -> serde_json::Value { diff --git a/src/App.vue b/src/App.vue index 999bd043fa..3f3f9a83ad 100644 --- a/src/App.vue +++ b/src/App.vue @@ -320,7 +320,8 @@ function onAiReplaceSql(sql: string) { function onAiExecuteSql(sql: string) { const tabId = ensureQueryTab(); queryStore.updateSql(tabId, sql); - nextTick(() => tryExecute()); + selectedSql.value = ""; + nextTick(() => tryExecute(sql)); } function handleKeydown(e: KeyboardEvent) {