Fixed issue with embedded_docs and db_fields
Bumped version also refs: hmarr/mongoengine#523
This commit is contained in:
parent
07f3e5356d
commit
5d8ffded40
@ -2,8 +2,9 @@
|
||||
Changelog
|
||||
=========
|
||||
|
||||
Changes in 0.6.X
|
||||
Changes in 0.6.13
|
||||
================
|
||||
- Fixed EmbeddedDocument db_field validation issue
|
||||
- Fixed StringField unicode issue
|
||||
- Fixes __repr__ modifying the cursor
|
||||
|
||||
|
@ -12,7 +12,7 @@ from signals import *
|
||||
__all__ = (document.__all__ + fields.__all__ + connection.__all__ +
|
||||
queryset.__all__ + signals.__all__)
|
||||
|
||||
VERSION = (0, 6, 12)
|
||||
VERSION = (0, 6, 13)
|
||||
|
||||
|
||||
def get_version():
|
||||
|
@ -957,6 +957,8 @@ class BaseDocument(object):
|
||||
try:
|
||||
data[field_name] = (value if value is None
|
||||
else field.to_python(value))
|
||||
if field_name != field.db_field:
|
||||
del data[field.db_field]
|
||||
except (AttributeError, ValueError), e:
|
||||
errors_dict[field_name] = e
|
||||
elif field.default:
|
||||
|
@ -5,7 +5,7 @@
|
||||
%define srcname mongoengine
|
||||
|
||||
Name: python-%{srcname}
|
||||
Version: 0.6.12
|
||||
Version: 0.6.13
|
||||
Release: 1%{?dist}
|
||||
Summary: A Python Document-Object Mapper for working with MongoDB
|
||||
|
||||
|
@ -1282,6 +1282,22 @@ class DocumentTest(unittest.TestCase):
|
||||
comment.date = datetime.now()
|
||||
comment.validate()
|
||||
|
||||
def test_embedded_db_field_validate(self):
|
||||
|
||||
class SubDoc(EmbeddedDocument):
|
||||
val = IntField()
|
||||
|
||||
class Doc(Document):
|
||||
e = EmbeddedDocumentField(SubDoc, db_field='eb')
|
||||
|
||||
Doc.drop_collection()
|
||||
|
||||
Doc(e=SubDoc(val=15)).save()
|
||||
|
||||
doc = Doc.objects.first()
|
||||
doc.validate()
|
||||
self.assertEquals([None, 'e'], doc._data.keys())
|
||||
|
||||
def test_save(self):
|
||||
"""Ensure that a document may be saved in the database.
|
||||
"""
|
||||
|
Loading…
x
Reference in New Issue
Block a user