Skip to content

Commit

Permalink
Quick and buggy fix to convert field with to_python in document setter
Browse files Browse the repository at this point in the history
  • Loading branch information
touilleMan committed Jul 10, 2015
1 parent bc7b4a9 commit a3919ef
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 2 additions & 0 deletions mongoengine/base/document.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,8 @@ def __setattr__(self, name, value):
self__created and name == self._meta.get('id_field')):
super(BaseDocument, self).__setattr__('_created', False)

if value is not None and name in self._fields:
value = self._fields[name].to_python(value)
super(BaseDocument, self).__setattr__(name, value)

def __getstate__(self):
Expand Down
1 change: 0 additions & 1 deletion tests/fields/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,6 @@ class Person(Document):
# How its stored
expected = [{'btc': '10.0000'}, {'btc': '10.1000'}, {'btc': '10.1100'},
{'btc': '10.1110'}, {'btc': '10.1111'}, {'btc': '10.1111'}]
expected = [{'btc': '10.0000'}]
actual = list(Person.objects.exclude('id').as_pymongo())
self.assertEqual(expected, actual)

Expand Down

0 comments on commit a3919ef

Please sign in to comment.