summaryrefslogtreecommitdiff
path: root/tests/invalid_models_tests
diff options
context:
space:
mode:
authorTim Graham <timograham@gmail.com>2016-09-09 18:52:34 -0400
committerTim Graham <timograham@gmail.com>2016-09-09 19:18:37 -0400
commite7abb5ba8608f90ce97c6edb031ae877195616f5 (patch)
tree96afdc6067842411825288c2e28a43c10b7a44ee /tests/invalid_models_tests
parent652bcc6f5fa9084768890488fec5208e082c2add (diff)
Fixed #27204 -- Made clashing m2m intermediary table checks ignore unmanaged models.
Diffstat (limited to 'tests/invalid_models_tests')
-rw-r--r--tests/invalid_models_tests/test_models.py30
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/invalid_models_tests/test_models.py b/tests/invalid_models_tests/test_models.py
index b37fca9922..1d27e98faa 100644
--- a/tests/invalid_models_tests/test_models.py
+++ b/tests/invalid_models_tests/test_models.py
@@ -830,6 +830,36 @@ class OtherModelTests(SimpleTestCase):
)
])
+ def test_m2m_unmanaged_shadow_models_not_checked(self):
+ class A1(models.Model):
+ pass
+
+ class C1(models.Model):
+ mm_a = models.ManyToManyField(A1, db_table='d1')
+
+ # Unmanaged models that shadow the above models. Reused table names
+ # shouldn't be flagged by any checks.
+ class A2(models.Model):
+ class Meta:
+ managed = False
+
+ class C2(models.Model):
+ mm_a = models.ManyToManyField(A2, through='Intermediate')
+
+ class Meta:
+ managed = False
+
+ class Intermediate(models.Model):
+ a2 = models.ForeignKey(A2, models.CASCADE, db_column='a1_id')
+ c2 = models.ForeignKey(C2, models.CASCADE, db_column='c1_id')
+
+ class Meta:
+ db_table = 'd1'
+ managed = False
+
+ self.assertEqual(C1.check(), [])
+ self.assertEqual(C2.check(), [])
+
@isolate_apps('django.contrib.auth', kwarg_name='apps')
def test_lazy_reference_checks(self, apps):
class DummyModel(models.Model):