From f1c1785959bb0738cfc880970c67e31763b42a11 Mon Sep 17 00:00:00 2001 From: t8y2 <1156263951@qq.com> Date: Tue, 15 Sep 2026 11:06:48 +0800 Subject: [PATCH] perf(query): avoid cloning result rows for JS serialization --- crates/dbx-core/src/query.rs | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) 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]