MCPcopy
hub / github.com/django/django / _is_relevant_relation

Function _is_relevant_relation

django/db/backends/base/schema.py:26–42  ·  view source on GitHub ↗

When altering the given field, must constraints on its model from the given relation be temporarily dropped?

(relation, altered_field)

Source from the content-addressed store, hash-verified

24
25
26def _is_relevant_relation(relation, altered_field):
27 """
28 When altering the given field, must constraints on its model from the given
29 relation be temporarily dropped?
30 """
31 field = relation.field
32 if field.many_to_many:
33 # M2M reverse field
34 return False
35 if altered_field.primary_key and field.to_fields == [None]:
36 # Foreign key constraint on the primary key, which is being altered.
37 return True
38 # Is the constraint targeting the field being altered?
39 return (
40 altered_field.name in field.to_fields
41 or altered_field.attname in field.to_fields
42 )
43
44
45def _all_related_fields(model):

Callers 1

_related_non_m2m_objectsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected