This disables optimization of RenameField operation when an old field
name is referenced in subsequent operations.
Co-authored-by: InvalidInterrupt <InvalidInterrupt@users.noreply.github.com>
This should alleviate the side effects of disabling the AlterFooOperation
reduction with RemoveField to fix refs #28862 during migration squashing
because CreateModel can perform a reduction with RemoveField.
Thanks Nick Pope for the review.
AlterFooTogether operations cannot be swapped with RemoveField operations on
the same model as they could be removing the the same field as well.
Since AlterFooTogether operations don't track what their previous value was,
it's impossible to determine whether or not the optimization is safe so the
only way to proceed is to disable the optimization.
Thanks Ramiro Morales for the in-depth analysis of the issue.
Refs #24828
An explicit intermediary many-to-many relationship must declare forward and
reverse foreign keys. The original issue was in the autodetector as these
operations shouldn't have been generated in this order in the first place
which is tested by AutodetectorTests.test_create_with_through_model.
The idea behind this change is, that AlterUniqueTogether,
AlterIndexTogether and AlterOrderWithRespectTo can always be moved after
an Add/Alter/Rename/RemoveField operation if they don't refer to the
respective field and are not empty sets / None.
Combined with the optimizations of duplicate AlterUniqueTogether,
AlterIndexTogether, and AlterOrderWithRespectTo operations from
128caa1e16, these operations are optimized
in a later round of the optimizer.
Thanks Tim Graham for the review.
This removes the concept of equality between operations to guarantee
compatilibity with Python 3.
Python 3 requires equality to result in identical object hashes. It's
impossible to implement a unique hash that preserves equality as
operations such as field creation depend on being able to accept
arbitrary dicts that cannot be hashed reliably.
Thanks Klaas van Schelven for the original patch in
13d613f800.