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