diff options
| author | Aymeric Augustin <aymeric.augustin@m4x.org> | 2013-01-28 10:17:56 +0100 |
|---|---|---|
| committer | Aymeric Augustin <aymeric.augustin@m4x.org> | 2013-01-28 10:17:56 +0100 |
| commit | f46d7314b50d71a75f51ebae9c5957cb96b11bd9 (patch) | |
| tree | 92f8cae7c72011609576ddfac414643ccf3c7a8f /tests | |
| parent | 14d1d504d5c839869a7f612b7d35fa1adf983f5b (diff) | |
Fixed #19677 -- Introspection of recursive foreign keys under SQLite.
Thanks Simon Charette.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/regressiontests/introspection/models.py | 1 | ||||
| -rw-r--r-- | tests/regressiontests/introspection/tests.py | 8 |
2 files changed, 7 insertions, 2 deletions
diff --git a/tests/regressiontests/introspection/models.py b/tests/regressiontests/introspection/models.py index 4de82e47e7..cfa72c9921 100644 --- a/tests/regressiontests/introspection/models.py +++ b/tests/regressiontests/introspection/models.py @@ -23,6 +23,7 @@ class Article(models.Model): headline = models.CharField(max_length=100) pub_date = models.DateField() reporter = models.ForeignKey(Reporter) + response_to = models.ForeignKey('self', null=True) def __str__(self): return self.headline diff --git a/tests/regressiontests/introspection/tests.py b/tests/regressiontests/introspection/tests.py index cd3e1cc8a4..0b4c49077d 100644 --- a/tests/regressiontests/introspection/tests.py +++ b/tests/regressiontests/introspection/tests.py @@ -106,13 +106,17 @@ class IntrospectionTests(TestCase): # should test that the response is correct. if relations: # That's {field_index: (field_index_other_table, other_table)} - self.assertEqual(relations, {3: (0, Reporter._meta.db_table)}) + self.assertEqual(relations, {3: (0, Reporter._meta.db_table), + 4: (0, Article._meta.db_table)}) @skipUnlessDBFeature('can_introspect_foreign_keys') def test_get_key_columns(self): cursor = connection.cursor() key_columns = connection.introspection.get_key_columns(cursor, Article._meta.db_table) - self.assertEqual(key_columns, [('reporter_id', Reporter._meta.db_table, 'id')]) + self.assertEqual( + set(key_columns), + set([('reporter_id', Reporter._meta.db_table, 'id'), + ('response_to_id', Article._meta.db_table, 'id')])) def test_get_primary_key_column(self): cursor = connection.cursor() |
