Merge branch 'master' of https://github.com/idoshr/mongoengine into idoshr-master

This commit is contained in:
Bastien Gerard 2021-09-30 20:38:32 +02:00
commit 558e3299fe
3 changed files with 22 additions and 0 deletions

View File

@ -262,3 +262,4 @@ that much better:
* Jan Stein (https://github.com/janste63) * Jan Stein (https://github.com/janste63)
* Timothé Perez (https://github.com/AchilleAsh) * Timothé Perez (https://github.com/AchilleAsh)
* oleksandr-l5 (https://github.com/oleksandr-l5) * oleksandr-l5 (https://github.com/oleksandr-l5)
* Ido Shraga (https://github.com/idoshr)

View File

@ -543,7 +543,10 @@ Documents may be updated atomically by using the
There are several different "modifiers" that you may use with these methods: There are several different "modifiers" that you may use with these methods:
* ``set`` -- set a particular value * ``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) * ``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 * ``inc`` -- increment a value by a given amount
* ``dec`` -- decrement a value by a given amount * ``dec`` -- decrement a value by a given amount
* ``push`` -- append a value to a list * ``push`` -- append a value to a list
@ -552,6 +555,7 @@ There are several different "modifiers" that you may use with these methods:
* ``pull`` -- remove a value from a list * ``pull`` -- remove a value from a list
* ``pull_all`` -- remove several values 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 * ``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/ .. _depending on the value: http://docs.mongodb.org/manual/reference/operator/update/pop/

View File

@ -867,6 +867,23 @@ class TestQueryset(unittest.TestCase):
assert "Bob" == bob.name assert "Bob" == bob.name
assert 30 == bob.age 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): def test_save_and_only_on_fields_with_default(self):
class Embed(EmbeddedDocument): class Embed(EmbeddedDocument):
field = IntField() field = IntField()