parent
1e51180d42
commit
ae39ed94c9
@ -4,6 +4,7 @@ Changelog
|
|||||||
|
|
||||||
Changes in 0.6.15
|
Changes in 0.6.15
|
||||||
=================
|
=================
|
||||||
|
- Fixed cascade save edge case
|
||||||
- Fixed geo index creation through reference fields
|
- Fixed geo index creation through reference fields
|
||||||
- Added support for args / kwargs when using @queryset_manager
|
- Added support for args / kwargs when using @queryset_manager
|
||||||
- Deref list custom id fix
|
- Deref list custom id fix
|
||||||
|
@ -248,11 +248,16 @@ class Document(BaseDocument):
|
|||||||
_refs = kwargs.get('_refs', []) or []
|
_refs = kwargs.get('_refs', []) or []
|
||||||
|
|
||||||
for name, cls in self._fields.items():
|
for name, cls in self._fields.items():
|
||||||
|
|
||||||
if not isinstance(cls, (ReferenceField, GenericReferenceField)):
|
if not isinstance(cls, (ReferenceField, GenericReferenceField)):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
ref = getattr(self, name)
|
ref = getattr(self, name)
|
||||||
if not ref:
|
if not ref:
|
||||||
continue
|
continue
|
||||||
|
if isinstance(ref, DBRef):
|
||||||
|
continue
|
||||||
|
|
||||||
ref_id = "%s,%s" % (ref.__class__.__name__, str(ref._data))
|
ref_id = "%s,%s" % (ref.__class__.__name__, str(ref._data))
|
||||||
if ref and ref_id not in _refs:
|
if ref and ref_id not in _refs:
|
||||||
_refs.append(ref_id)
|
_refs.append(ref_id)
|
||||||
|
@ -3186,5 +3186,29 @@ name: Field is required ("name")"""
|
|||||||
p = Person(age=15)
|
p = Person(age=15)
|
||||||
self.assertRaises(ValidationError, p.validate)
|
self.assertRaises(ValidationError, p.validate)
|
||||||
|
|
||||||
|
def test_cascaded_save_wrong_reference(self):
|
||||||
|
|
||||||
|
class ADocument(Document):
|
||||||
|
val = IntField()
|
||||||
|
|
||||||
|
class BDocument(Document):
|
||||||
|
a = ReferenceField(ADocument)
|
||||||
|
|
||||||
|
ADocument.drop_collection()
|
||||||
|
BDocument.drop_collection()
|
||||||
|
|
||||||
|
a = ADocument()
|
||||||
|
a.val = 15
|
||||||
|
a.save()
|
||||||
|
|
||||||
|
b = BDocument()
|
||||||
|
b.a = a
|
||||||
|
b.save()
|
||||||
|
|
||||||
|
a.delete()
|
||||||
|
|
||||||
|
b = BDocument.objects.first()
|
||||||
|
b.save(cascade=True)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user