Skip to content

armgit / dbx

Public Imported from GitHub
0

25 MB lightweight cross-platform database client for 100+ databases, including MySQL, PostgreSQL, SQLite, Redis, MongoDB, DuckDB, SQL Server, and Dameng. Built-in AI, MCP Server, CLI, desktop and Docker. | 轻量级跨平台数据库管理工具,支持 MySQL、PostgreSQL、SQLite、Redis、MongoDB、达梦等 100+ 数据库,提供桌面端、Docker、CLI、内置 AI 助手和 MCP。

fix: fallback agent batch execution errors (#2113)

zipg55bfa11bd146
diff --git a/crates/dbx-core/src/query.rs b/crates/dbx-core/src/query.rs
index 554d0549d9..bdae7d9f4d 100644
--- a/crates/dbx-core/src/query.rs
+++ b/crates/dbx-core/src/query.rs
@@ -1861,7 +1861,7 @@ pub async fn execute_statements(
match result {
Ok(result) => return Ok(db::QueryResult { execution_time_ms: start.elapsed().as_millis(), ..result }),
Err(err) => {
- if err.contains("Unknown method: execute_batch") {
+ if is_agent_execute_batch_unsupported(&err) {
log::warn!(
"Agent does not support execute_batch; falling back to statement-by-statement execution"
);
@@ -1928,6 +1928,11 @@ pub async fn execute_statements(
})
}
+fn is_agent_execute_batch_unsupported(error: &str) -> bool {
+ let lower = error.to_lowercase();
+ lower.contains("execute_batch") && (lower.contains("unknown method") || lower.contains("method not found"))
+}
+
/// Execute multiple SQL statements within a single transaction.
/// For pooled drivers (Postgres/MySQL), uses the driver transaction API.
/// For SQLite and already-single-connection drivers (ClickHouse/SqlServer/Agent),
@@ -2404,6 +2409,19 @@ mod tests {
}
}
+ #[test]
+ fn agent_execute_batch_unsupported_detects_case_insensitive_method_errors() {
+ assert!(is_agent_execute_batch_unsupported("Agent RPC error (-1): unknown method: execute_batch"));
+ assert!(is_agent_execute_batch_unsupported("Agent RPC error (-1): Unknown method: execute_batch"));
+ assert!(is_agent_execute_batch_unsupported("Agent RPC error (-32601): Method not found: execute_batch"));
+ }
+
+ #[test]
+ fn agent_execute_batch_unsupported_ignores_unrelated_errors() {
+ assert!(!is_agent_execute_batch_unsupported("ORA-00955: name is already used by an existing object"));
+ assert!(!is_agent_execute_batch_unsupported("Agent RPC error (-1): unknown method: execute_query"));
+ }
+
#[tokio::test]
async fn wait_for_query_returns_cancelled_when_token_is_cancelled() {
let token = CancellationToken::new();