forked from django/django
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed #28305 -- Fixed "Cannot change column 'x': used in a foreign ke…
…y constraint" crash on MySQL with a sequence of AlterField or RenameField operations. Regression in 45ded05.
- Loading branch information
Showing
5 changed files
with
113 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
def is_referenced_by_foreign_key(state, model_name_lower, field, field_name): | ||
for state_app_label, state_model in state.models: | ||
for _, f in state.models[state_app_label, state_model].fields: | ||
if (f.related_model and | ||
'%s.%s' % (state_app_label, model_name_lower) == f.related_model.lower() and | ||
hasattr(f, 'to_fields')): | ||
if (f.to_fields[0] is None and field.primary_key) or field_name in f.to_fields: | ||
return True | ||
return False |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters