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。

refactor(grid): cover every extractor variant in the clipboard guard

ordinary being37b1c061d5cf
diff --git a/crates/dbx-core/src/data/grid_clipboard_guard.rs b/crates/dbx-core/src/data/grid_clipboard_guard.rs
index 2589e2b76e..d625f63bb2 100644
--- a/crates/dbx-core/src/data/grid_clipboard_guard.rs
+++ b/crates/dbx-core/src/data/grid_clipboard_guard.rs
@@ -41,17 +41,37 @@ use serde_json::Value;
/// evaluates any pasted field that starts with a trigger character. `PipeSeparated`
/// and `Dsv` are the same shape. The one-row and CSV writers are RFC4180 records, so
/// Excel treats their fields the same way.
+///
+/// Written as an exhaustive match with no `_` arm on purpose. The extractor dispatch
+/// in `dbx-sql-data` is exhaustive too, so a new variant already fails to build there;
+/// this is the cross-crate half of that contract. Without it, a variant added for a
+/// new spreadsheet-bound format would be handled by the dispatch yet silently skip the
+/// guard here, because nothing in `dbx-core` would mention it.
fn is_spreadsheet_extractor(extractor: DataGridExtractorId) -> bool {
- matches!(
- extractor,
+ match extractor {
DataGridExtractorId::Tsv
- | DataGridExtractorId::TsvWithHeaders
- | DataGridExtractorId::Csv
- | DataGridExtractorId::CsvWithHeaders
- | DataGridExtractorId::PipeSeparated
- | DataGridExtractorId::Dsv
- | DataGridExtractorId::OneRow
- )
+ | DataGridExtractorId::TsvWithHeaders
+ | DataGridExtractorId::Csv
+ | DataGridExtractorId::CsvWithHeaders
+ | DataGridExtractorId::PipeSeparated
+ | DataGridExtractorId::Dsv
+ | DataGridExtractorId::OneRow => true,
+
+ // Not spreadsheet cells: a leading apostrophe would corrupt the document or
+ // the statement, and the raw extractor must stay byte-exact.
+ DataGridExtractorId::Raw
+ | DataGridExtractorId::Json
+ | DataGridExtractorId::JsonLines
+ | DataGridExtractorId::SqlInList
+ | DataGridExtractorId::SqlInserts
+ | DataGridExtractorId::SqlUpdates
+ | DataGridExtractorId::SqlSelect
+ | DataGridExtractorId::WhereClause
+ | DataGridExtractorId::Markdown
+ | DataGridExtractorId::Html
+ | DataGridExtractorId::Xml
+ | DataGridExtractorId::Pretty => false,
+ }
}
/// Returns the request with spreadsheet-triggering text cells prefixed by `'`.