diff options
| author | Simon Charette <charette.s@gmail.com> | 2020-04-17 00:39:24 -0400 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2020-04-21 08:37:40 +0200 |
| commit | a54828085732d5d2f020c2fb52fe1cbe1a20a6c9 (patch) | |
| tree | 9b4c3a127e2a32c0973240a10b0564a399cb1db4 /tests | |
| parent | 2ba55b29050e68bf312cab0a4f512fc6fd01e619 (diff) | |
Fixed #31064 -- Recreated auto-created many-to-many tables on primary key data type change on SQLite.
Both local and remote auto-created many-to-many relationships were
affected.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/migrations/test_operations.py | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/migrations/test_operations.py b/tests/migrations/test_operations.py index 162a14d529..051b8036b5 100644 --- a/tests/migrations/test_operations.py +++ b/tests/migrations/test_operations.py @@ -1275,6 +1275,16 @@ class OperationTests(OperationTestBase): Tests the AlterField operation on primary keys changes any FKs pointing to it. """ project_state = self.set_up_test_model("test_alflpkfk", related_model=True) + project_state = self.apply_operations('test_alflpkfk', project_state, [ + migrations.CreateModel('Stable', fields=[ + ('ponies', models.ManyToManyField('Pony')), + ]), + migrations.AddField( + 'Pony', + 'stables', + models.ManyToManyField('Stable'), + ), + ]) # Test the state alteration operation = migrations.AlterField("Pony", "id", models.FloatField(primary_key=True)) new_state = project_state.clone() @@ -1294,8 +1304,26 @@ class OperationTests(OperationTestBase): for c in connection.introspection.get_table_description(cursor, "test_alflpkfk_rider") if c.name == "pony_id" ][0] + m2m_fk_type, m2m_fk_null = [ + (c.type_code, c.null_ok) + for c in connection.introspection.get_table_description( + cursor, + 'test_alflpkfk_pony_stables', + ) if c.name == 'pony_id' + ][0] + remote_m2m_fk_type, remote_m2m_fk_null = [ + (c.type_code, c.null_ok) + for c in connection.introspection.get_table_description( + cursor, + 'test_alflpkfk_stable_ponies', + ) if c.name == 'pony_id' + ][0] self.assertEqual(id_type, fk_type) + self.assertEqual(id_type, m2m_fk_type) + self.assertEqual(id_type, remote_m2m_fk_type) self.assertEqual(id_null, fk_null) + self.assertEqual(id_null, m2m_fk_null) + self.assertEqual(id_null, remote_m2m_fk_null) assertIdTypeEqualsFkType() # Test the database alteration |
