Fix documentation of Queryset.update regarding full_result #1995
This commit is contained in:
		| @@ -7,6 +7,7 @@ Development | |||||||
| - (Fill this out as you fix issues and develop your features). | - (Fill this out as you fix issues and develop your features). | ||||||
| - Fix .only() working improperly after using .count() of the same instance of QuerySet | - Fix .only() working improperly after using .count() of the same instance of QuerySet | ||||||
| - POTENTIAL BREAKING CHANGE: All result fields are now passed, including internal fields (_cls, _id) when using `QuerySet.as_pymongo` #1976 | - POTENTIAL BREAKING CHANGE: All result fields are now passed, including internal fields (_cls, _id) when using `QuerySet.as_pymongo` #1976 | ||||||
|  | - Document a BREAKING CHANGE introduced in 0.15.3 and not reported at that time (#1995) | ||||||
|  |  | ||||||
| ================= | ================= | ||||||
| Changes in 0.16.3 | Changes in 0.16.3 | ||||||
| @@ -64,6 +65,7 @@ Changes in 0.16.0 | |||||||
|  |  | ||||||
| Changes in 0.15.3 | Changes in 0.15.3 | ||||||
| ================= | ================= | ||||||
|  | -  BREAKING CHANGES: `Queryset.update/update_one` methods now returns an UpdateResult when `full_result=True` is provided and no longer a dict (relates to #1491) | ||||||
| -  Subfield resolve error in generic_emdedded_document query #1651 #1652 | -  Subfield resolve error in generic_emdedded_document query #1651 #1652 | ||||||
| -  use each modifier only with $position #1673 #1675 | -  use each modifier only with $position #1673 #1675 | ||||||
| -  Improve LazyReferenceField and GenericLazyReferenceField with nested fields #1704 | -  Improve LazyReferenceField and GenericLazyReferenceField with nested fields #1704 | ||||||
|   | |||||||
| @@ -498,11 +498,12 @@ class BaseQuerySet(object): | |||||||
|             ``save(..., write_concern={w: 2, fsync: True}, ...)`` will |             ``save(..., write_concern={w: 2, fsync: True}, ...)`` will | ||||||
|             wait until at least two servers have recorded the write and |             wait until at least two servers have recorded the write and | ||||||
|             will force an fsync on the primary server. |             will force an fsync on the primary server. | ||||||
|         :param full_result: Return the full result dictionary rather than just the number |         :param full_result: Return the associated ``pymongo.UpdateResult`` rather than just the number | ||||||
|             updated, e.g. return |             updated items | ||||||
|             ``{'n': 2, 'nModified': 2, 'ok': 1.0, 'updatedExisting': True}``. |  | ||||||
|         :param update: Django-style update keyword arguments |         :param update: Django-style update keyword arguments | ||||||
|  |  | ||||||
|  |         :returns the number of updated documents (unless ``full_result`` is True) | ||||||
|  |  | ||||||
|         .. versionadded:: 0.2 |         .. versionadded:: 0.2 | ||||||
|         """ |         """ | ||||||
|         if not update and not upsert: |         if not update and not upsert: | ||||||
| @@ -566,7 +567,7 @@ class BaseQuerySet(object): | |||||||
|             document = self._document.objects.with_id(atomic_update.upserted_id) |             document = self._document.objects.with_id(atomic_update.upserted_id) | ||||||
|         return document |         return document | ||||||
|  |  | ||||||
|     def update_one(self, upsert=False, write_concern=None, **update): |     def update_one(self, upsert=False, write_concern=None, full_result=False, **update): | ||||||
|         """Perform an atomic update on the fields of the first document |         """Perform an atomic update on the fields of the first document | ||||||
|         matched by the query. |         matched by the query. | ||||||
|  |  | ||||||
| @@ -577,12 +578,19 @@ class BaseQuerySet(object): | |||||||
|             ``save(..., write_concern={w: 2, fsync: True}, ...)`` will |             ``save(..., write_concern={w: 2, fsync: True}, ...)`` will | ||||||
|             wait until at least two servers have recorded the write and |             wait until at least two servers have recorded the write and | ||||||
|             will force an fsync on the primary server. |             will force an fsync on the primary server. | ||||||
|  |         :param full_result: Return the associated ``pymongo.UpdateResult`` rather than just the number | ||||||
|  |             updated items | ||||||
|         :param update: Django-style update keyword arguments |         :param update: Django-style update keyword arguments | ||||||
|  |             full_result | ||||||
|  |         :returns the number of updated documents (unless ``full_result`` is True) | ||||||
|         .. versionadded:: 0.2 |         .. versionadded:: 0.2 | ||||||
|         """ |         """ | ||||||
|         return self.update( |         return self.update( | ||||||
|             upsert=upsert, multi=False, write_concern=write_concern, **update) |             upsert=upsert, | ||||||
|  |             multi=False, | ||||||
|  |             write_concern=write_concern, | ||||||
|  |             full_result=full_result, | ||||||
|  |             **update) | ||||||
|  |  | ||||||
|     def modify(self, upsert=False, full_response=False, remove=False, new=False, **update): |     def modify(self, upsert=False, full_response=False, remove=False, new=False, **update): | ||||||
|         """Update and return the updated document. |         """Update and return the updated document. | ||||||
|   | |||||||
| @@ -2233,6 +2233,19 @@ class QuerySetTest(unittest.TestCase): | |||||||
|         bar.reload() |         bar.reload() | ||||||
|         self.assertEqual(len(bar.foos), 0) |         self.assertEqual(len(bar.foos), 0) | ||||||
|  |  | ||||||
|  |     def test_update_one_check_return_with_full_result(self): | ||||||
|  |         class BlogTag(Document): | ||||||
|  |             name = StringField(required=True) | ||||||
|  |  | ||||||
|  |         BlogTag.drop_collection() | ||||||
|  |  | ||||||
|  |         BlogTag(name='garbage').save() | ||||||
|  |         default_update = BlogTag.objects.update_one(name='new') | ||||||
|  |         self.assertEqual(default_update, 1) | ||||||
|  |  | ||||||
|  |         full_result_update = BlogTag.objects.update_one(name='new', full_result=True) | ||||||
|  |         self.assertIsInstance(full_result_update, UpdateResult) | ||||||
|  |  | ||||||
|     def test_update_one_pop_generic_reference(self): |     def test_update_one_pop_generic_reference(self): | ||||||
|  |  | ||||||
|         class BlogTag(Document): |         class BlogTag(Document): | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user