diff options
| author | Tom Wojcik <me@tomwojcik.com> | 2021-07-20 12:44:13 +0200 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2021-07-26 06:41:31 +0200 |
| commit | b2f7b53facc7c3432b9d6173276f4baff02e71b7 (patch) | |
| tree | b4e2ccb7debace5d57d2bbba4e3884502023600e /tests/invalid_models_tests | |
| parent | de5a044cf49ba3d856388fe008f1e1a82a69b699 (diff) | |
[3.2.x] Fixed #32947 -- Fixed hash() crash on reverse M2M relation when through_fields is a list.
Regression in c32d8f33d8e988a376e44997b8f3606d821f305e.
Backport of 20226fcd461670334646f78a0c4d133e439b12b2 from main
Diffstat (limited to 'tests/invalid_models_tests')
| -rw-r--r-- | tests/invalid_models_tests/test_models.py | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/invalid_models_tests/test_models.py b/tests/invalid_models_tests/test_models.py index ab9daad13a..b4c7938687 100644 --- a/tests/invalid_models_tests/test_models.py +++ b/tests/invalid_models_tests/test_models.py @@ -821,6 +821,33 @@ class ShadowingFieldsTests(SimpleTestCase): ) ]) + def test_field_name_clash_with_m2m_through(self): + class Parent(models.Model): + clash_id = models.IntegerField() + + class Child(Parent): + clash = models.ForeignKey('Child', models.CASCADE) + + class Model(models.Model): + parents = models.ManyToManyField( + to=Parent, + through='Through', + through_fields=['parent', 'model'], + ) + + class Through(models.Model): + parent = models.ForeignKey(Parent, models.CASCADE) + model = models.ForeignKey(Model, models.CASCADE) + + self.assertEqual(Child.check(), [ + Error( + "The field 'clash' clashes with the field 'clash_id' from " + "model 'invalid_models_tests.parent'.", + obj=Child._meta.get_field('clash'), + id='models.E006', + ) + ]) + def test_multiinheritance_clash(self): class Mother(models.Model): clash = models.IntegerField() |
