Skip to content

Commit

Permalink
Merge pull request #2571 from bagerard/idoshr-master-fixed
Browse files Browse the repository at this point in the history
Idoshr master fixed
  • Loading branch information
bagerard committed Sep 30, 2021
2 parents 5fe9436 + 28226f8 commit 0af1a11
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 1 deletion.
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -262,3 +262,4 @@ that much better:
* Jan Stein (https://github.com/janste63)
* Timothé Perez (https://github.com/AchilleAsh)
* oleksandr-l5 (https://github.com/oleksandr-l5)
* Ido Shraga (https://github.com/idoshr)
4 changes: 4 additions & 0 deletions docs/guide/querying.rst
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,10 @@ Documents may be updated atomically by using the
There are several different "modifiers" that you may use with these methods:

* ``set`` -- set a particular value
* ``set_on_insert`` -- set only if this is new document `need to add upsert=True`_
* ``unset`` -- delete a particular value (since MongoDB v1.3)
* ``max`` -- update only if value is bigger
* ``min`` -- update only if value is smaller
* ``inc`` -- increment a value by a given amount
* ``dec`` -- decrement a value by a given amount
* ``push`` -- append a value to a list
Expand All @@ -552,6 +555,7 @@ There are several different "modifiers" that you may use with these methods:
* ``pull`` -- remove a value from a list
* ``pull_all`` -- remove several values from a list
* ``add_to_set`` -- add value to a list only if its not in the list already
* ``rename`` -- rename the key name

.. _depending on the value: http://docs.mongodb.org/manual/reference/operator/update/pop/

Expand Down
2 changes: 1 addition & 1 deletion mongoengine/queryset/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -720,7 +720,7 @@ def with_id(self, object_id):
return queryset.filter(pk=object_id).first()

def in_bulk(self, object_ids):
""" "Retrieve a set of documents by their ids.
"""Retrieve a set of documents by their ids.
:param object_ids: a list or tuple of ObjectId's
:rtype: dict of ObjectId's as keys and collection-specific
Expand Down
15 changes: 15 additions & 0 deletions tests/queryset/test_queryset.py
Original file line number Diff line number Diff line change
Expand Up @@ -867,6 +867,21 @@ def test_set_on_insert(self):
assert "Bob" == bob.name
assert 30 == bob.age

def test_rename(self):
self.Person.drop_collection()
self.Person.objects.create(name="Foo", age=11)

bob = self.Person.objects.as_pymongo().first()
assert "age" in bob
assert bob["age"] == 11

self.Person.objects(name="Foo").update(rename__age="person_age")

bob = self.Person.objects.as_pymongo().first()
assert "age" not in bob
assert "person_age" in bob
assert bob["person_age"] == 11

def test_save_and_only_on_fields_with_default(self):
class Embed(EmbeddedDocument):
field = IntField()
Expand Down

0 comments on commit 0af1a11

Please sign in to comment.