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。

perf(query): avoid cloning result rows for JS serialization

t8y2f1c1785959bb
diff --git a/crates/dbx-core/src/query.rs b/crates/dbx-core/src/query.rs
index 8977fe0a78..843ffa4f76 100644
--- a/crates/dbx-core/src/query.rs
+++ b/crates/dbx-core/src/query.rs
@@ -1200,11 +1200,6 @@ pub fn truncate_result_with_max_rows(mut result: db::QueryResult, max_rows: Opti
result
}
-fn normalize_query_result_for_js(mut result: db::QueryResult) -> db::QueryResult {
- result.rows = result.rows.into_iter().map(|row| row.into_iter().map(db::json_value_for_js).collect()).collect();
- result
-}
-
pub fn agent_execute_query_params(
sql: &str,
database: Option<&str>,
@@ -2345,7 +2340,6 @@ async fn do_execute_typed(
PoolKind::Consul(_) => Err("SQL execution is not supported for Consul connections".to_string()),
};
result
- .map(normalize_query_result_for_js)
.map_err(|error| {
#[cfg(feature = "duckdb-sidecar")]
if let Some(duckdb_error) = typed_duckdb_error {
@@ -10446,10 +10440,10 @@ for line in sys.stdin:
messages: Vec::new(),
};
- let normalized = normalize_query_result_for_js(result);
+ let serialized = serde_json::to_value(result).unwrap();
- assert_eq!(normalized.rows[0][0], serde_json::json!("2041797190226354178"));
- assert_eq!(normalized.rows[0][1], serde_json::json!([1, "2041797190226354178"]));
+ assert_eq!(serialized["rows"][0][0], serde_json::json!("2041797190226354178"));
+ assert_eq!(serialized["rows"][0][1], serde_json::json!([1, "2041797190226354178"]));
}
#[test]