From bafecb5bd157e82a8f0172933bc1199b3ce6fdfa Mon Sep 17 00:00:00 2001 From: Sean Sullivan Date: Tue, 2 Jul 2024 12:50:18 -0400 Subject: [PATCH] Add support for bitwise operators --- mongomock/collection.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/mongomock/collection.py b/mongomock/collection.py index c7e86c946..e729f75c1 100644 --- a/mongomock/collection.py +++ b/mongomock/collection.py @@ -2130,8 +2130,16 @@ def _current_date_updater(doc, field_name, value): else: doc[field_name] = mongomock.utcnow() +def _bit_updater(doc,field_name,value): + if value.get("or"): + doc[field] = doc[field] | value["or"] + if value.get("and"): + doc[field] = doc[field] & value["and"] + if value.get("xor"): + doc[field] = doc[field] | value["xor"] _updaters = { + '$bit': _bit_updater, '$set': _set_updater, '$unset': _unset_updater, '$inc': _inc_updater,