From dcdee9538c4f1c7ffbff885d20d5fc2240442f7f Mon Sep 17 00:00:00 2001 From: maiconpavi <75434446+maiconpavi@users.noreply.github.com> Date: Tue, 30 May 2023 09:47:23 -0300 Subject: [PATCH] chaging replace document serialization The Insert uses `human_readable = false` to serialize documents, but the Replace uses `bson::to_document` that uses `human_readable = true`. --- src/coll/mod.rs | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/coll/mod.rs b/src/coll/mod.rs index 9999393a4..2524832ab 100644 --- a/src/coll/mod.rs +++ b/src/coll/mod.rs @@ -2,6 +2,7 @@ pub mod options; use std::{borrow::Borrow, collections::HashSet, fmt, fmt::Debug, sync::Arc}; +use bson::{to_document_with_options, SerializerOptions}; use futures_util::{ future, stream::{StreamExt, TryStreamExt}, @@ -15,7 +16,7 @@ use serde::{ use self::options::*; use crate::{ - bson::{doc, to_document, Bson, Document}, + bson::{doc, Bson, Document}, bson_util, change_stream::{ event::ChangeStreamEvent, @@ -1119,7 +1120,12 @@ where options: impl Into>, session: impl Into>, ) -> Result> { - let replacement = to_document(replacement.borrow())?; + let replacement = to_document_with_options( + replacement.borrow(), + SerializerOptions::builder() + .human_readable(Some(false)) + .build(), + )?; let session = session.into(); @@ -1379,7 +1385,12 @@ where options: impl Into>, session: impl Into>, ) -> Result { - let replacement = to_document(replacement.borrow())?; + let replacement = to_document_with_options( + replacement.borrow(), + SerializerOptions::builder() + .human_readable(Some(false)) + .build(), + )?; bson_util::replacement_document_check(&replacement)?;