Fixed #24576 -- Made deletion of related objects deterministic.
This commit is contained in:
parent
1f29164ced
commit
7862cbda86
|
@ -64,7 +64,7 @@ class Collector(object):
|
|||
def __init__(self, using):
|
||||
self.using = using
|
||||
# Initially, {model: {instances}}, later values become lists.
|
||||
self.data = {}
|
||||
self.data = OrderedDict()
|
||||
self.field_updates = {} # {model: {(field, value): {instances}}}
|
||||
# fast_deletes is a list of queryset-likes that can be deleted without
|
||||
# fetching the objects into memory.
|
||||
|
|
|
@ -224,12 +224,13 @@ class DeletionTests(TestCase):
|
|||
s2 = S.objects.create(pk=2, r=r)
|
||||
T.objects.create(pk=1, s=s1)
|
||||
T.objects.create(pk=2, s=s2)
|
||||
RChild.objects.create(r_ptr=r)
|
||||
r.delete()
|
||||
self.assertEqual(
|
||||
pre_delete_order, [(T, 2), (T, 1), (S, 2), (S, 1), (R, 1)]
|
||||
pre_delete_order, [(T, 2), (T, 1), (RChild, 1), (S, 2), (S, 1), (R, 1)]
|
||||
)
|
||||
self.assertEqual(
|
||||
post_delete_order, [(T, 1), (T, 2), (S, 1), (S, 2), (R, 1)]
|
||||
post_delete_order, [(T, 1), (T, 2), (RChild, 1), (S, 1), (S, 2), (R, 1)]
|
||||
)
|
||||
|
||||
models.signals.post_delete.disconnect(log_post_delete)
|
||||
|
|
Loading…
Reference in New Issue