diff options
| author | Jacob Kaplan-Moss <jacob@jacobian.org> | 2009-04-09 15:03:31 +0000 |
|---|---|---|
| committer | Jacob Kaplan-Moss <jacob@jacobian.org> | 2009-04-09 15:03:31 +0000 |
| commit | c0ad626dca67fe2e0c1dce3c5db524cfa77a9884 (patch) | |
| tree | c38c717bbecb2b312a7761fa990f558d011d8b59 /tests | |
| parent | f55f2b9d74bf59d1b3ace5df5f498998eb62cb28 (diff) | |
Fixed #10647: intermediary tables between two umanaged models are no longer created.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@10455 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/modeltests/unmanaged_models/models.py | 21 | ||||
| -rw-r--r-- | tests/modeltests/unmanaged_models/tests.py | 22 |
2 files changed, 43 insertions, 0 deletions
diff --git a/tests/modeltests/unmanaged_models/models.py b/tests/modeltests/unmanaged_models/models.py index 717c8d5b3a..4402090582 100644 --- a/tests/modeltests/unmanaged_models/models.py +++ b/tests/modeltests/unmanaged_models/models.py @@ -89,6 +89,27 @@ class Intermediate(models.Model): db_table = 'D01' managed = False +# +# These next models test the creation (or not) of many to many join tables +# between managed and unmanaged models. A join table between two unmanaged +# models shouldn't be automatically created (see #10647). +# +class Unmanaged1(models.Model): + class Meta: + managed = False + +# Unmanged with an m2m to unmanaged: the intermediary table won't be created. +class Unmanaged2(models.Model): + mm = models.ManyToManyField(Unmanaged1) + + class Meta: + managed = False + +# Here's an unmanaged model with an m2m to a managed one; the intermediary +# table *will* be created (unless given a custom `through` as for C02 above). +class Managed1(models.Model): + mm = models.ManyToManyField(Unmanaged1) + __test__ = {'API_TESTS':""" The main test here is that the all the models can be created without any database errors. We can also do some more simple insertion and lookup tests diff --git a/tests/modeltests/unmanaged_models/tests.py b/tests/modeltests/unmanaged_models/tests.py new file mode 100644 index 0000000000..c5f14bd3df --- /dev/null +++ b/tests/modeltests/unmanaged_models/tests.py @@ -0,0 +1,22 @@ +from django.test import TestCase +from django.db import connection +from models import Unmanaged1, Unmanaged2, Managed1 + +class ManyToManyUnmanagedTests(TestCase): + + def test_many_to_many_between_unmanaged(self): + """ + The intermediary table between two unmanaged models should not be created. + """ + table = Unmanaged2._meta.get_field('mm').m2m_db_table() + tables = connection.introspection.table_names() + self.assert_(table not in tables, "Table '%s' should not exist, but it does." % table) + + def test_many_to_many_between_unmanaged_and_managed(self): + """ + An intermediary table between a managed and an unmanaged model should be created. + """ + table = Managed1._meta.get_field('mm').m2m_db_table() + tables = connection.introspection.table_names() + self.assert_(table in tables, "Table '%s' does not exist." % table) +
\ No newline at end of file |
