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(mongodb): reject unknown update options instead of dropping
Loc Nguyen91b8fa0aa83e
diff --git a/crates/dbx-core/src/db/mongo_driver.rs b/crates/dbx-core/src/db/mongo_driver.rsindex e9a10ec807..47680a920d 100644--- a/crates/dbx-core/src/db/mongo_driver.rs+++ b/crates/dbx-core/src/db/mongo_driver.rs@@ -2164,8 +2164,11 @@ fn parse_replace_options(options_json: Option<&str>) -> Result<Option<bool>, StrOk(options.upsert)}+/// Unknown options are rejected rather than dropped, so a `collation` or `hint` the+/// driver does not apply fails loudly instead of silently changing nothing. This+/// matches `MongoReplaceOptions` and the legacy agent, which already reject them.#[derive(Default, Deserialize)]-#[serde(rename_all = "camelCase")]+#[serde(rename_all = "camelCase", deny_unknown_fields)]struct MongoUpdateOptions {upsert: Option<bool>,array_filters: Option<Vec<serde_json::Value>>,@@ -3290,6 +3293,16 @@ mod tests {assert!(value_error.contains("object or pipeline array"));}+ #[test]+ fn update_options_reject_unknown_fields_instead_of_dropping_them() {+ let error = parse_update_options(Some(r#"{"upsert":true,"collation":{"locale":"en"}}"#)).unwrap_err();+ assert!(error.contains("collation"), "{error}");+ // Same rule as replace: an option the driver would not apply must not be silently ignored.+ assert!(parse_replace_options(Some(r#"{"upsert":true,"collation":{"locale":"en"}}"#)).is_err());+ assert!(parse_update_options(Some("{}")).is_ok());+ assert!(parse_update_options(None).is_ok());+ }+#[test]fn update_options_parse_upsert_and_array_filters() {let options =