Removed hardcoded pks in migrations' test_alter_order_with_respect_to.

This commit is contained in:
Tim Graham 2020-11-07 14:26:01 -05:00 committed by GitHub
parent 354c1524b3
commit 84ca7b8602
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 3 deletions

View File

@ -248,7 +248,7 @@ class OperationTestBase(MigrationTestBase):
[
('id', models.AutoField(primary_key=True)),
('pony', models.ForeignKey('Pony', models.CASCADE)),
('friend', models.ForeignKey('self', models.CASCADE))
('friend', models.ForeignKey('self', models.CASCADE, null=True))
],
))
if mti_model:

View File

@ -2541,8 +2541,12 @@ class OperationTests(OperationTestBase):
# Create some rows before alteration
rendered_state = project_state.apps
pony = rendered_state.get_model("test_alorwrtto", "Pony").objects.create(weight=50)
rendered_state.get_model("test_alorwrtto", "Rider").objects.create(pony=pony, friend_id=1)
rendered_state.get_model("test_alorwrtto", "Rider").objects.create(pony=pony, friend_id=2)
rider1 = rendered_state.get_model("test_alorwrtto", "Rider").objects.create(pony=pony)
rider1.friend = rider1
rider1.save()
rider2 = rendered_state.get_model("test_alorwrtto", "Rider").objects.create(pony=pony)
rider2.friend = rider2
rider2.save()
# Test the database alteration
with connection.schema_editor() as editor:
operation.database_forwards("test_alorwrtto", editor, project_state, new_state)