fix: don't update the same field while trying to remove it

fixes #392
This commit is contained in:
IAmTomahawkx
2025-08-06 14:18:40 -07:00
parent 6048587d34
commit f4ee35fb09

View File

@@ -212,6 +212,23 @@ impl AbstractUsers for MongoDb {
partial: &PartialUser, partial: &PartialUser,
remove: Vec<FieldsUser>, remove: Vec<FieldsUser>,
) -> Result<()> { ) -> Result<()> {
if remove.contains(&FieldsUser::StatusText) && partial.status.is_some() {
// stupid-ass workaround to fix mongo conflicting the same item
let _: Result<()> = query!(
self,
update_one_by_id,
COL,
id,
PartialUser {
..Default::default()
},
remove.iter().map(|x| x as &dyn IntoDocumentPath).collect(),
None
)
.map(|_| ());
query!(self, update_one_by_id, COL, id, partial, vec![], None).map(|_| ())
} else {
query!( query!(
self, self,
update_one_by_id, update_one_by_id,
@@ -223,6 +240,7 @@ impl AbstractUsers for MongoDb {
) )
.map(|_| ()) .map(|_| ())
} }
}
/// Set relationship with another user /// Set relationship with another user
/// ///