@@ -600,9 +600,7 @@ def update_one(self, upsert=False, write_concern=None, full_result=False, **upda
600
600
** update
601
601
)
602
602
603
- def modify (
604
- self , upsert = False , full_response = False , remove = False , new = False , ** update
605
- ):
603
+ def modify (self , upsert = False , remove = False , new = False , ** update ):
606
604
"""Update and return the updated document.
607
605
608
606
Returns either the document before or after modification based on `new`
@@ -616,8 +614,6 @@ def modify(
616
614
information about the command's execution.
617
615
618
616
:param upsert: insert if document doesn't exist (default ``False``)
619
- :param full_response: return the entire response object from the
620
- server (default ``False``, not available for PyMongo 3+)
621
617
:param remove: remove rather than updating (default ``False``)
622
618
:param new: return updated rather than original document
623
619
(default ``False``)
@@ -639,9 +635,6 @@ def modify(
639
635
sort = queryset ._ordering
640
636
641
637
try :
642
- if full_response :
643
- msg = "With PyMongo 3+, it is not possible anymore to get the full response."
644
- warnings .warn (msg , DeprecationWarning )
645
638
if remove :
646
639
result = queryset ._collection .find_one_and_delete (
647
640
query , sort = sort , ** self ._cursor_args
@@ -664,14 +657,8 @@ def modify(
664
657
except pymongo .errors .OperationFailure as err :
665
658
raise OperationError (u"Update failed (%s)" % err )
666
659
667
- if full_response :
668
- if result ["value" ] is not None :
669
- result ["value" ] = self ._document ._from_son (
670
- result ["value" ], only_fields = self .only_fields
671
- )
672
- else :
673
- if result is not None :
674
- result = self ._document ._from_son (result , only_fields = self .only_fields )
660
+ if result is not None :
661
+ result = self ._document ._from_son (result , only_fields = self .only_fields )
675
662
676
663
return result
677
664
@@ -1594,25 +1581,23 @@ def _collection(self):
1594
1581
1595
1582
@property
1596
1583
def _cursor_args (self ):
1597
- fields_name = "projection"
1598
- # snapshot is not handled at all by PyMongo 3+
1599
- # TODO: evaluate similar possibilities using modifiers
1600
- if self ._snapshot :
1601
- msg = "The snapshot option is not anymore available with PyMongo 3+"
1602
- warnings .warn (msg , DeprecationWarning )
1584
+ projection_field_name = "projection"
1603
1585
1604
1586
cursor_args = {}
1605
1587
if not self ._timeout :
1606
1588
cursor_args ["no_cursor_timeout" ] = True
1607
1589
1590
+ if self ._snapshot :
1591
+ cursor_args ["modifiers" ] = {"$snapshot" : True }
1592
+
1608
1593
if self ._loaded_fields :
1609
- cursor_args [fields_name ] = self ._loaded_fields .as_dict ()
1594
+ cursor_args [projection_field_name ] = self ._loaded_fields .as_dict ()
1610
1595
1611
1596
if self ._search_text :
1612
- if fields_name not in cursor_args :
1613
- cursor_args [fields_name ] = {}
1597
+ if projection_field_name not in cursor_args :
1598
+ cursor_args [projection_field_name ] = {}
1614
1599
1615
- cursor_args [fields_name ]["_text_score" ] = {"$meta" : "textScore" }
1600
+ cursor_args [projection_field_name ]["_text_score" ] = {"$meta" : "textScore" }
1616
1601
1617
1602
return cursor_args
1618
1603
0 commit comments