Refs #27272 -- Added Collector.add_dependency().

This commit is contained in:
Daniel Izquierdo 2019-10-22 09:47:18 +02:00 committed by Mariusz Felisiak
parent 33eecfa740
commit 4e1d809aa5
1 changed files with 7 additions and 3 deletions

View File

@ -102,11 +102,15 @@ class Collector:
# deleting, and therefore do not affect the order in which objects have # deleting, and therefore do not affect the order in which objects have
# to be deleted. # to be deleted.
if source is not None and not nullable: if source is not None and not nullable:
if reverse_dependency: self.add_dependency(source, model, reverse_dependency=reverse_dependency)
source, model = model, source
self.dependencies[source._meta.concrete_model].add(model._meta.concrete_model)
return new_objs return new_objs
def add_dependency(self, model, dependency, reverse_dependency=False):
if reverse_dependency:
model, dependency = dependency, model
self.dependencies[model._meta.concrete_model].add(dependency._meta.concrete_model)
self.data.setdefault(dependency, self.data.default_factory())
def add_field_update(self, field, value, objs): def add_field_update(self, field, value, objs):
""" """
Schedule a field update. 'objs' must be a homogeneous iterable Schedule a field update. 'objs' must be a homogeneous iterable