mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
Fixed #31499 -- Stored ModelState.fields into a dict.
This allows the removal of its O(n) .get_field_by_name method and many other awkward access patterns. While fields were initially stored in a list to preserve the initial model definiton field ordering the auto-detector doesn't take field ordering into account and no operations exists to reorder fields of a model. This makes the preservation of the field ordering completely superflous because field reorganization after the creation of the model state wouldn't be taken into account.
This commit is contained in:
committed by
Mariusz Felisiak
parent
696024fb73
commit
06889d6206
@@ -516,13 +516,13 @@ class ExecutorTests(MigrationTestBase):
|
||||
state = executor.migrate([
|
||||
('mutate_state_a', '0001_initial'),
|
||||
])
|
||||
self.assertIn('added', dict(state.models['mutate_state_b', 'b'].fields))
|
||||
self.assertIn('added', state.models['mutate_state_b', 'b'].fields)
|
||||
executor.loader.build_graph()
|
||||
# Migrate backward.
|
||||
state = executor.migrate([
|
||||
('mutate_state_a', None),
|
||||
])
|
||||
self.assertIn('added', dict(state.models['mutate_state_b', 'b'].fields))
|
||||
self.assertIn('added', state.models['mutate_state_b', 'b'].fields)
|
||||
executor.migrate([
|
||||
('mutate_state_b', None),
|
||||
])
|
||||
|
||||
Reference in New Issue
Block a user