Refs #27768 -- Reversed order of optimized and in-between operations.
Operations can only be optimized through if they don't reference any of the state the operation they are compared against defines or alters, so it's safe to reverse the order.
This commit is contained in:
parent
529c3f264d
commit
d3a935f01f
|
@ -47,9 +47,10 @@ class MigrationOptimizer:
|
|||
in_between = operations[i + 1:i + j + 1]
|
||||
result = operation.reduce(other, in_between, app_label)
|
||||
if isinstance(result, list):
|
||||
# Optimize! Add result, then remaining others, then return
|
||||
new_operations.extend(result)
|
||||
# Add operations optimized through, optimized operations,
|
||||
# and the remaining ones.
|
||||
new_operations.extend(in_between)
|
||||
new_operations.extend(result)
|
||||
new_operations.extend(operations[i + j + 2:])
|
||||
return new_operations
|
||||
if not result:
|
||||
|
|
|
@ -1165,8 +1165,8 @@ class AutodetectorTests(TestCase):
|
|||
# Right number/type of migrations?
|
||||
self.assertNumberMigrations(changes, 'testapp', 1)
|
||||
self.assertOperationTypes(changes, 'testapp', 0, ["CreateModel", "CreateModel"])
|
||||
self.assertOperationAttributes(changes, "testapp", 0, 0, name="Author")
|
||||
self.assertOperationAttributes(changes, "testapp", 0, 1, name="Publisher")
|
||||
self.assertOperationAttributes(changes, "testapp", 0, 0, name="Publisher")
|
||||
self.assertOperationAttributes(changes, "testapp", 0, 1, name="Author")
|
||||
self.assertMigrationDependencies(changes, 'testapp', 0, [("otherapp", "auto_1")])
|
||||
# Right number/type of migrations?
|
||||
self.assertNumberMigrations(changes, 'otherapp', 2)
|
||||
|
|
Loading…
Reference in New Issue