Skip to content

Commit

Permalink
Fixed db_field load error
Browse files Browse the repository at this point in the history
  • Loading branch information
rozza committed Jun 18, 2012
1 parent 89a6eee commit 9e7ea64
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 48 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ env/
.settings
.project
.pydevproject
tests/bugfix.py
tests/test_bugfix.py
htmlcov/
1 change: 1 addition & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Changelog

Changes in 0.6.X
================
- Fixed db_field data load error
- Fixed recursive save with FileField

Changes in 0.6.10
Expand Down
1 change: 1 addition & 0 deletions mongoengine/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -798,6 +798,7 @@ def __init__(self, **values):
dynamic_data[key] = value
else:
for key, value in values.items():
key = self._reverse_db_field_map.get(key, key)
setattr(self, key, value)

# Set any get_fieldname_display methods
Expand Down
47 changes: 0 additions & 47 deletions tests/test_bugfix.py

This file was deleted.

20 changes: 20 additions & 0 deletions tests/test_document.py
Original file line number Diff line number Diff line change
Expand Up @@ -664,6 +664,26 @@ class ExtendedBlogPost(BlogPost):

BlogPost.drop_collection()

def test_db_field_load(self):
"""Ensure we load data correctly
"""
class Person(Document):
name = StringField(required=True)
_rank = StringField(required=False, db_field="rank")

@property
def rank(self):
return self._rank or "Private"

Person.drop_collection()

Person(name="Jack", _rank="Corporal").save()

Person(name="Fred").save()

self.assertEquals(Person.objects.get(name="Jack").rank, "Corporal")
self.assertEquals(Person.objects.get(name="Fred").rank, "Private")

def test_explicit_geo2d_index(self):
"""Ensure that geo2d indexes work when created via meta[indexes]
"""
Expand Down

0 comments on commit 9e7ea64

Please sign in to comment.