Skip to content

Commit 0b69e83

Browse files
committed
CR
1 parent 2f3afce commit 0b69e83

File tree

3 files changed

+4
-7
lines changed

3 files changed

+4
-7
lines changed

docs/changelog.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Development
88
===========
99
- (Fill this out as you fix issues and develop your features).
1010
- Fix for uuidRepresentation not read when provided in URI #2741
11-
- Add option to user array_filters https://www.mongodb.com/docs/manual/reference/operator/update/positional-filtered/
11+
- Add option to user array_filters https://www.mongodb.com/docs/manual/reference/operator/update/positional-filtered/ #2769
1212
- Fix combination of __raw__ and mongoengine syntax #2773
1313
- Add tests against MongoDB 6.0 and MongoDB 7.0 in the pipeline
1414
- Fix validate() not being called when inheritance is used in EmbeddedDocument and validate is overriden #2784

docs/guide/querying.rst

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -261,9 +261,8 @@ This is done by using ``__raw__`` keyword argument to the update method and prov
261261
::
262262

263263
# assuming an initial 'tags' field == ['test1', 'test2', 'test3']
264-
Page.objects().update(__raw__=
265-
{'$set': {"tags.$[element]": 'test11111'}},
266-
'array_filters': [{"element": {'$eq': 'test2'}}],
264+
Page.objects().update(__raw__={'$set': {"tags.$[element]": 'test11111'}},
265+
array_filters=[{"element": {'$eq': 'test2'}}],
267266

268267
# updated 'tags' field == ['test1', 'test11111', 'test3']
269268

mongoengine/queryset/base.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -562,14 +562,12 @@ def update(
562562

563563
queryset = self.clone()
564564
query = queryset._query
565-
if "__raw__" in update and isinstance(update["__raw__"], list):
565+
if "__raw__" in update and isinstance(update["__raw__"], list): # Case of Update with Aggregation Pipeline
566566
update = [
567567
transform.update(queryset._document, **{"__raw__": u})
568568
for u in update["__raw__"]
569569
]
570570
else:
571-
if "array_filters" in update:
572-
array_filters = update.pop("array_filters")
573571
update = transform.update(queryset._document, **update)
574572
# If doing an atomic upsert on an inheritable class
575573
# then ensure we add _cls to the update operation

0 commit comments

Comments
 (0)