MCPcopy
hub / github.com/django/django / add

Method add

django/db/models/deletion.py:141–163  ·  view source on GitHub ↗

Add 'objs' to the collection of objects to be deleted. If the call is the result of a cascade, 'source' should be the model that caused it, and 'nullable' should be set to True if the relation can be null. Return a list of all objects that were not already collected

(self, objs, source=None, nullable=False, reverse_dependency=False)

Source from the content-addressed store, hash-verified

139 self.dependencies = defaultdict(set) # {model: {models}}
140
141 def add(self, objs, source=None, nullable=False, reverse_dependency=False):
142 """
143 Add 'objs' to the collection of objects to be deleted. If the call is
144 the result of a cascade, 'source' should be the model that caused it,
145 and 'nullable' should be set to True if the relation can be null.
146
147 Return a list of all objects that were not already collected.
148 """
149 if not objs:
150 return []
151 new_objs = []
152 model = objs[0].__class__
153 instances = self.data[model]
154 for obj in objs:
155 if obj not in instances:
156 new_objs.append(obj)
157 instances.update(new_objs)
158 # Nullable relationships can be ignored -- they are nulled out before
159 # deleting, and therefore do not affect the order in which objects have
160 # to be deleted.
161 if source is not None and not nullable:
162 self.add_dependency(source, model, reverse_dependency=reverse_dependency)
163 return new_objs
164
165 def add_dependency(self, model, dependency, reverse_dependency=False):
166 if reverse_dependency:

Callers 15

collectMethod · 0.95
_non_atomic_requestsFunction · 0.45
sql_flushMethod · 0.45
_alter_fieldMethod · 0.45
get_table_descriptionMethod · 0.45
get_constraintsMethod · 0.45
_alter_fieldMethod · 0.45
init_connection_stateMethod · 0.45
django_table_namesMethod · 0.45
load_diskMethod · 0.45

Calls 3

add_dependencyMethod · 0.95
appendMethod · 0.45
updateMethod · 0.45

Tested by

no test coverage detected