diff options
| author | Daniel Patrick <github@danielpatrick.dev> | 2024-07-03 19:23:59 +0100 |
|---|---|---|
| committer | Sarah Boyce <42296566+sarahboyce@users.noreply.github.com> | 2024-07-10 08:40:50 +0200 |
| commit | d12184fedcd586e2c399ea40abe4bf865ebc87a6 (patch) | |
| tree | f25d6b9adea7ccbe7f443a3d2a4383319bf14bc5 /tests/migrations/test_state.py | |
| parent | e095c7612d49dbe371e9c7edd76ba99b6bc4f9f6 (diff) | |
Fixed #35424 -- Checked order_with_respect_to is available when migrating _order fields.
Migrations would crash following the removal of an order_with_respect_to
field from a model and the addition of an _order field.
Diffstat (limited to 'tests/migrations/test_state.py')
| -rw-r--r-- | tests/migrations/test_state.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/migrations/test_state.py b/tests/migrations/test_state.py index c64e4ebb4d..dbbdf77734 100644 --- a/tests/migrations/test_state.py +++ b/tests/migrations/test_state.py @@ -1131,6 +1131,22 @@ class StateTests(SimpleTestCase): self.assertIsNone(order_field.related_model) self.assertIsInstance(order_field, models.PositiveSmallIntegerField) + def test_get_order_field_after_removed_order_with_respect_to_field(self): + new_apps = Apps() + + class HistoricalRecord(models.Model): + _order = models.PositiveSmallIntegerField() + + class Meta: + app_label = "migrations" + apps = new_apps + + model_state = ModelState.from_model(HistoricalRecord) + model_state.options["order_with_respect_to"] = None + order_field = model_state.get_field("_order") + self.assertIsNone(order_field.related_model) + self.assertIsInstance(order_field, models.PositiveSmallIntegerField) + def test_manager_refer_correct_model_version(self): """ #24147 - Managers refer to the correct version of a |
