Merge branch 'bug/318' into dev
Conflicts: AUTHORS
This commit is contained in:
commit
fbe8b28b2e
1
AUTHORS
1
AUTHORS
@ -76,3 +76,4 @@ that much better:
|
||||
* Adam Parrish
|
||||
* jpfarias
|
||||
* jonrscott
|
||||
* Alice Zoë Bevan-McGregor
|
||||
|
@ -5,6 +5,7 @@ Changelog
|
||||
Changes in dev
|
||||
==============
|
||||
|
||||
- Fixed dereferencing - multi directional list dereferencing
|
||||
- Fixed issue creating indexes with recursive embedded documents
|
||||
- Fixed recursive lookup in _unique_with_indexes
|
||||
- Fixed passing ComplexField defaults to constructor for ReferenceFields
|
||||
|
@ -168,9 +168,9 @@ class DeReference(object):
|
||||
elif isinstance(v, (dict, pymongo.son.SON)) and '_ref' in v:
|
||||
data[k]._data[field_name] = self.object_map.get(v['_ref'].id, v)
|
||||
elif isinstance(v, dict) and depth <= self.max_depth:
|
||||
data[k]._data[field_name] = self._attach_objects(v, depth - 1, instance=instance, name=name)
|
||||
data[k]._data[field_name] = self._attach_objects(v, depth, instance=instance, name=name)
|
||||
elif isinstance(v, (list, tuple)) and depth <= self.max_depth:
|
||||
data[k]._data[field_name] = self._attach_objects(v, depth - 1, instance=instance, name=name)
|
||||
data[k]._data[field_name] = self._attach_objects(v, depth, instance=instance, name=name)
|
||||
elif isinstance(v, (dict, list, tuple)) and depth <= self.max_depth:
|
||||
data[k] = self._attach_objects(v, depth - 1, instance=instance, name=name)
|
||||
elif hasattr(v, 'id'):
|
||||
|
@ -760,3 +760,26 @@ class FieldTest(unittest.TestCase):
|
||||
UserB.drop_collection()
|
||||
UserC.drop_collection()
|
||||
Group.drop_collection()
|
||||
|
||||
def test_multidirectional_lists(self):
|
||||
|
||||
class Asset(Document):
|
||||
name = StringField(max_length=250, required=True)
|
||||
parent = GenericReferenceField(default=None)
|
||||
parents = ListField(GenericReferenceField())
|
||||
children = ListField(GenericReferenceField())
|
||||
|
||||
Asset.drop_collection()
|
||||
|
||||
root = Asset(name='', path="/", title="Site Root")
|
||||
root.save()
|
||||
|
||||
company = Asset(name='company', title='Company', parent=root, parents=[root])
|
||||
company.save()
|
||||
|
||||
root.children = [company]
|
||||
root.save()
|
||||
|
||||
root = root.reload()
|
||||
self.assertEquals(root.children, [company])
|
||||
self.assertEquals(company.parents, [root])
|
||||
|
Loading…
x
Reference in New Issue
Block a user