Skip to content

Commit

Permalink
Merge pull request #879 from DavidBord/fix-866
Browse files Browse the repository at this point in the history
Fix #866:  does not follow
  • Loading branch information
DavidBord committed Feb 16, 2015
2 parents 0205d82 + 5c3d91e commit aca8899
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Changelog

Changes in 0.9.X - DEV
======================
- `BaseDict` does not follow `setdefault` #866
- Add support for $type operator # 766
- Fix tests for pymongo 2.8+ #877
- No module named 'django.utils.importlib' (Django dev) #872
Expand Down
4 changes: 4 additions & 0 deletions mongoengine/base/datastructures.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ def popitem(self, *args, **kwargs):
self._mark_as_changed()
return super(BaseDict, self).popitem(*args, **kwargs)

def setdefault(self, *args, **kwargs):
self._mark_as_changed()
return super(BaseDict, self).setdefault(*args, **kwargs)

def update(self, *args, **kwargs):
self._mark_as_changed()
return super(BaseDict, self).update(*args, **kwargs)
Expand Down
5 changes: 5 additions & 0 deletions tests/fields/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -1176,6 +1176,11 @@ class BlogPost(Document):
post.reload()
self.assertEqual('updated', post.info['title'])

post.info.setdefault('authors', [])
post.save()
post.reload()
self.assertEqual([], post.info['authors'])

BlogPost.drop_collection()

def test_dictfield_strict(self):
Expand Down

0 comments on commit aca8899

Please sign in to comment.