parent
89a6eee6af
commit
9e7ea64bd2
2
.gitignore
vendored
2
.gitignore
vendored
@ -13,5 +13,5 @@ env/
|
||||
.settings
|
||||
.project
|
||||
.pydevproject
|
||||
tests/bugfix.py
|
||||
tests/test_bugfix.py
|
||||
htmlcov/
|
@ -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
|
||||
|
@ -798,6 +798,7 @@ class BaseDocument(object):
|
||||
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
|
||||
|
@ -1,47 +0,0 @@
|
||||
# import pickle
|
||||
# import pymongo
|
||||
# import bson
|
||||
# import warnings
|
||||
|
||||
# from datetime import datetime
|
||||
|
||||
# import tempfile
|
||||
# import pymongo, gridfs
|
||||
|
||||
import unittest
|
||||
from mongoengine import *
|
||||
from bson.objectid import ObjectId
|
||||
|
||||
class BugFixTest(unittest.TestCase):
|
||||
|
||||
|
||||
def setUp(self):
|
||||
|
||||
conn = connect(db='mongoenginetest')
|
||||
|
||||
def test_items_list(self):
|
||||
|
||||
class ActivityType1(EmbeddedDocument):
|
||||
activity_id = IntField()
|
||||
activity_name = StringField()
|
||||
|
||||
class ActivityType2(EmbeddedDocument):
|
||||
activity_id = IntField()
|
||||
activity_status = StringField()
|
||||
|
||||
class UserActivities(Document):
|
||||
user_id = IntField()
|
||||
activity = GenericEmbeddedDocumentField(choices=(ActivityType1, ActivityType2))
|
||||
|
||||
|
||||
UserActivities.drop_collection()
|
||||
|
||||
user_id = 123
|
||||
activity_id = 321
|
||||
UserActivities(user_id=user_id, activity=ActivityType2(activity_id=activity_id, activity_status="A")).save()
|
||||
|
||||
self.assertEquals(1, UserActivities.objects(user_id=user_id, __raw__={'activity.activity_status': 'A'}).count())
|
||||
|
||||
|
||||
|
||||
|
@ -664,6 +664,26 @@ class DocumentTest(unittest.TestCase):
|
||||
|
||||
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]
|
||||
"""
|
||||
|
Loading…
x
Reference in New Issue
Block a user