Ticket #30591: ticket-30591.diff

File ticket-30591.diff, 2.5 KB (added by Mariusz Felisiak, 3 years ago)
  • tests/migrations/test_operations.py

    diff --git a/tests/migrations/test_operations.py b/tests/migrations/test_operations.py
    index 3b2129a933..9adad168b1 100644
    a b class OperationTests(OperationTestBase): 
    14581458            operation.database_backwards("test_alflpkfk", editor, new_state, project_state)
    14591459        assertIdTypeEqualsFkType()
    14601460
     1461    @skipUnlessDBFeature('supports_foreign_keys')
     1462    def test_alter_field_reloads_state_on_fk_with_to_field_target_type_change(self):
     1463        app_label = 'alter_alter_field_reloads_state_on_fk_with_to_field_target_type_change'
     1464        project_state = self.apply_operations(app_label, ProjectState(), operations=[
     1465            migrations.CreateModel('Rider', fields=[
     1466                ('id', models.AutoField(primary_key=True)),
     1467                ('code', models.PositiveIntegerField(unique=True)),
     1468            ]),
     1469            migrations.CreateModel('Pony', fields=[
     1470                ('id', models.AutoField(primary_key=True)),
     1471                ('rider', models.ForeignKey('%s.Rider' % app_label, models.CASCADE, to_field='code')),
     1472            ]),
     1473        ])
     1474        project_state = self.apply_operations(app_label, project_state, operations=[
     1475            migrations.AlterField('Rider', 'code', models.CharField(max_length=100, unique=True)),
     1476        ])
     1477
     1478    @skipUnlessDBFeature('supports_foreign_keys')
     1479    def test_alter_field_reloads_state_on_fk_with_to_field_related_name_target_type_change(self):
     1480        app_label = 'alter_alter_field_reloads_state_on_fk_with_to_field_related_name_target_type_change'
     1481        project_state = self.apply_operations(app_label, ProjectState(), operations=[
     1482            migrations.CreateModel('Rider', fields=[
     1483                ('id', models.AutoField(primary_key=True)),
     1484                ('code', models.PositiveIntegerField(unique=True)),
     1485            ]),
     1486            migrations.CreateModel('Pony', fields=[
     1487                ('id', models.AutoField(primary_key=True)),
     1488                ('rider', models.ForeignKey('%s.Rider' % app_label, models.CASCADE, to_field='code', related_name='+')),
     1489            ]),
     1490        ])
     1491        project_state = self.apply_operations(app_label, project_state, operations=[
     1492            migrations.AlterField('Rider', 'code', models.CharField(max_length=100, unique=True)),
     1493        ])
     1494
    14611495    def test_alter_field_reloads_state_on_fk_target_changes(self):
    14621496        """
    14631497        If AlterField doesn't reload state appropriately, the second AlterField
Back to Top