mirror of
https://github.com/django/django.git
synced 2025-08-30 23:37:50 +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:
parent
696024fb73
commit
06889d6206
9 changed files with 104 additions and 112 deletions
|
@ -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),
|
||||
])
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue