File tree Expand file tree Collapse file tree 3 files changed +2
-11
lines changed Expand file tree Collapse file tree 3 files changed +2
-11
lines changed Original file line number Diff line number Diff line change @@ -236,7 +236,7 @@ keyword argument::
236236Update with Aggregation Pipeline
237237-----------
238238It is possible to provide a raw :mod: `PyMongo ` aggregation update parameter, which will
239- be integrated directly into the update. This is done using the `` aggregation_update=True `` and `` __raw__ ``
239+ be integrated directly into the update. This is done by using `` __raw__ `` field and value of array
240240pipeline
241241`Update with Aggregation Pipeline <https://docs.mongodb.com/manual/reference/method/db.collection.updateMany/#update-with-aggregation- >`_
242242keyword argument::
@@ -245,7 +245,6 @@ keyword argument::
245245 Page.objects(tags='coding').update(__raw__=[
246246 {"$set": {"tags": {"$concat": ["$tags", "is fun"]}}}
247247 ],
248- aggregation_update=True,
249248 )
250249
251250.. versionadded :: 0.4
Original file line number Diff line number Diff line change @@ -524,7 +524,6 @@ def update(
524524 write_concern = None ,
525525 read_concern = None ,
526526 full_result = False ,
527- aggregation_update = False ,
528527 ** update ,
529528 ):
530529 """Perform an atomic update on the fields matched by the query.
@@ -540,7 +539,6 @@ def update(
540539 :param read_concern: Override the read concern for the operation
541540 :param full_result: Return the associated ``pymongo.UpdateResult`` rather than just the number
542541 updated items
543- :param aggregation_update: Update with Aggregation Pipeline https://docs.mongodb.com/manual/reference/method/db.collection.updateMany/#update-with-aggregation-pipeline
544542 :param update: Django-style update keyword arguments
545543
546544 :returns the number of updated documents (unless ``full_result`` is True)
@@ -553,11 +551,7 @@ def update(
553551
554552 queryset = self .clone ()
555553 query = queryset ._query
556- if aggregation_update :
557- if "__raw__" not in update :
558- raise OperationError (
559- "Currently aggregation_update works only with __raw__ value"
560- )
554+ if "__raw__" in update and isinstance (update ["__raw__" ], list ):
561555 update = [
562556 transform .update (queryset ._document , ** {"__raw__" : u })
563557 for u in update ["__raw__" ]
Original file line number Diff line number Diff line change @@ -2233,7 +2233,6 @@ class BlogPost(Document):
22332233
22342234 BlogPost .objects (slug = "test" ).update (
22352235 __raw__ = [{"$set" : {"slug" : {"$concat" : ["$slug" , " " , "$slug" ]}}}],
2236- aggregation_update = True ,
22372236 )
22382237 post .reload ()
22392238 assert post .slug == "test test"
@@ -2245,7 +2244,6 @@ class BlogPost(Document):
22452244 "$set" : {"slug" : {"$concat" : ["When" , " " , "$slug" ]}}
22462245 }, # When test test it
22472246 ],
2248- aggregation_update = True ,
22492247 )
22502248 post .reload ()
22512249 assert post .slug == "When test test it"
You can’t perform that action at this time.
0 commit comments