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.
This commit is contained in:
t8y2
2026-05-08 16:45:01 +08:00
parent ae890092dd
commit 92fe47b913
2 changed files with 16 additions and 3 deletions
+14 -2
View File
@@ -17,10 +17,22 @@ pub async fn connect(
) -> Result<OracleClient, String> {
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 {
+2 -1
View File
@@ -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) {