Prevent evolution issues with same field names across different models.
Review Request #7163 — Created April 4, 2015 and submitted
If two fields were being mutated in two different models in the same mutation run, and both fields had the same name, the mutator could end up contaminated the state for one or both. This could result in mutations being dropped on the floor or modified in some way. Luckily, this would all be caught when it came time to diff and simulate, but it did mean some people couldn't upgrade their databases if applied mutations that were getting "optimized" out. An example that was hit in the wild is a ChangeField in one model, followed by an AddField in another, both mutating the same field name. The optimizer would try to condense this into a single AddField, to prevent the ChangeField from having to apply to the database, even though these were different models. To solve this, we simply include the model name in all keys used for the state tracking. A unit test was added that reproduced the problem found in the wild.
Unit tests failed before this, as did the real-world database upgrade.
After, they both succeeded. (Well, the database upgrade failed, but due
to reasons entirely outside of django-evolution.)
Description | From | Last Updated |
---|---|---|
'AddField' imported but unused |
reviewbot |
- Change Summary:
-
Fixed an unused import.
- Commit:
-
331619cc8b38254c235d0517dad0d172c4b5f54daffcf7f275acd60779ac76eec635ff9245960bee