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。
TypeScript aicliclickhousedatabasedatabase-clientdatabase-managementdockerguimcpmongodbmysqlpostgresqlredisrustsql-serversqlitetaurivue
fix(export): omit BOM from JSON files
t8y205841277d143
diff --git a/src-tauri/src/commands/text_export.rs b/src-tauri/src/commands/text_export.rsindex 7e3267ea33..2844397fb4 100644--- a/src-tauri/src/commands/text_export.rs+++ b/src-tauri/src/commands/text_export.rs@@ -16,15 +16,17 @@ impl QueryResultTextExportRequest {}}+fn write_query_result_json(request: QueryResultTextExportRequest) -> Result<(), String> {+ let file_path = request.file_path.clone();+ let content = format_json(&request.into_data())?;+ std::fs::write(file_path, content).map_err(|err| err.to_string())+}+#[tauri::command]pub async fn export_query_result_json(request: QueryResultTextExportRequest) -> Result<(), String> {- tauri::async_runtime::spawn_blocking(move || {- let file_path = request.file_path.clone();- let content = format_json(&request.into_data())?;- std::fs::write(file_path, format!("\u{FEFF}{content}")).map_err(|err| err.to_string())- })- .await- .map_err(|err| err.to_string())?+ tauri::async_runtime::spawn_blocking(move || write_query_result_json(request))+ .await+ .map_err(|err| err.to_string())?}#[tauri::command]@@ -37,3 +39,27 @@ pub async fn export_query_result_markdown(request: QueryResultTextExportRequest).await.map_err(|err| err.to_string())?}++#[cfg(test)]+mod tests {+ use serde_json::{json, Value};++ use super::{write_query_result_json, QueryResultTextExportRequest};++ #[test]+ fn writes_json_without_utf8_bom() {+ let path = std::env::temp_dir().join(format!("dbx-json-export-{}.json", uuid::Uuid::new_v4()));+ write_query_result_json(QueryResultTextExportRequest {+ file_path: path.to_string_lossy().into_owned(),+ columns: vec!["id".to_string(), "name".to_string()],+ rows: vec![vec![json!(1), json!("Ada")]],+ })+ .unwrap();++ let bytes = std::fs::read(&path).unwrap();+ let _ = std::fs::remove_file(&path);++ assert!(!bytes.starts_with(b"\xEF\xBB\xBF"));+ assert_eq!(serde_json::from_slice::<Value>(&bytes).unwrap(), json!([{ "id": 1, "name": "Ada" }]));+ }+}