Merge branch 'master' of https://github.com/gregbanks/mongoengine
This commit is contained in:
commit
a4a8c94374
@ -112,6 +112,10 @@ class DeReference(object):
|
||||
for ref in references:
|
||||
if '_cls' in ref:
|
||||
doc = get_document(ref["_cls"])._from_son(ref)
|
||||
elif doc_type is None:
|
||||
doc = get_document(
|
||||
''.join(x.capitalize()
|
||||
for x in col.split('_')))._from_son(ref)
|
||||
else:
|
||||
doc = doc_type._from_son(ref)
|
||||
object_map[doc.id] = doc
|
||||
|
@ -810,3 +810,34 @@ class FieldTest(unittest.TestCase):
|
||||
room = Room.objects.first().select_related()
|
||||
self.assertEquals(room.staffs_with_position[0]['staff'], sarah)
|
||||
self.assertEquals(room.staffs_with_position[1]['staff'], bob)
|
||||
|
||||
def test_document_reload_no_inheritance(self):
|
||||
class Foo(Document):
|
||||
meta = {'allow_inheritance': False}
|
||||
bar = ReferenceField('Bar')
|
||||
baz = ReferenceField('Baz')
|
||||
|
||||
class Bar(Document):
|
||||
meta = {'allow_inheritance': False}
|
||||
msg = StringField(required=True, default='Blammo!')
|
||||
|
||||
class Baz(Document):
|
||||
meta = {'allow_inheritance': False}
|
||||
msg = StringField(required=True, default='Kaboom!')
|
||||
|
||||
Foo.drop_collection()
|
||||
Bar.drop_collection()
|
||||
Baz.drop_collection()
|
||||
|
||||
bar = Bar()
|
||||
bar.save()
|
||||
baz = Baz()
|
||||
baz.save()
|
||||
foo = Foo()
|
||||
foo.bar = bar
|
||||
foo.baz = baz
|
||||
foo.save()
|
||||
foo.reload()
|
||||
|
||||
self.assertEquals(type(foo.bar), Bar)
|
||||
self.assertEquals(type(foo.baz), Baz)
|
||||
|
Loading…
x
Reference in New Issue
Block a user