Skip to content

Commit

Permalink
Merge pull request #881 from DavidBord/fix-863
Browse files Browse the repository at this point in the history
Fix #863: Request Support for $min, $max Field update operators
  • Loading branch information
DavidBord committed Feb 18, 2015
2 parents aca8899 + 129632c commit baf79dd
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
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
======================
- Request Support for $min, $max Field update operators #863
- `BaseDict` does not follow `setdefault` #866
- Add support for $type operator # 766
- Fix tests for pymongo 2.8+ #877
Expand Down
2 changes: 1 addition & 1 deletion mongoengine/queryset/transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

UPDATE_OPERATORS = ('set', 'unset', 'inc', 'dec', 'pop', 'push',
'push_all', 'pull', 'pull_all', 'add_to_set',
'set_on_insert')
'set_on_insert', 'min', 'max')


def query(_doc_cls=None, _field_operation=False, **query):
Expand Down
11 changes: 11 additions & 0 deletions tests/queryset/queryset.py
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,17 @@ class BlogPost(Document):
self.assertEqual(post.comments[0].by, 'joe')
self.assertEqual(post.comments[0].votes.score, 4)

def test_update_min_max(self):
class Scores(Document):
high_score = IntField()
low_score = IntField()
scores = Scores(high_score=800, low_score=200)
scores.save()
Scores.objects(id=scores.id).update(min__low_score=150)
self.assertEqual(Scores.objects(id=scores.id).get().low_score, 150)
Scores.objects(id=scores.id).update(min__low_score=250)
self.assertEqual(Scores.objects(id=scores.id).get().low_score, 150)

def test_updates_can_have_match_operators(self):

class Comment(EmbeddedDocument):
Expand Down

0 comments on commit baf79dd

Please sign in to comment.