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。

test(export): parse quoted csv fields in assertion

t8y2066019446575
diff --git a/crates/dbx-core/src/table_export.rs b/crates/dbx-core/src/table_export.rs
index 77a9f16f76..c6b29a1e33 100644
--- a/crates/dbx-core/src/table_export.rs
+++ b/crates/dbx-core/src/table_export.rs
@@ -333,9 +333,13 @@ mod tests {
let out = format_csv_rows(&rows);
assert!(out.contains("\"hello,world\""));
assert!(out.contains("\"line1\nline2\""));
- // CSV escaping wraps in quotes, so commas inside are safe
- let fields: Vec<&str> = out.split(',').collect();
- assert_eq!(fields.len(), 2);
+ let records: Vec<Vec<String>> = csv::ReaderBuilder::new()
+ .has_headers(false)
+ .from_reader(out.as_bytes())
+ .records()
+ .map(|record| record.unwrap().iter().map(str::to_string).collect())
+ .collect();
+ assert_eq!(records, vec![vec!["hello,world".to_string(), "line1\nline2".to_string()]]);
}
// -----------------------------------------------------------------------