summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAnssi Kääriäinen <akaariai@gmail.com>2012-04-30 14:05:30 +0300
committerAnssi Kääriäinen <akaariai@gmail.com>2012-04-30 14:30:29 +0300
commita18e43c5bb8cb7c82c84ca1b42d847a62ac9f077 (patch)
tree296fb370abf2407e008d0849f013dac4e457e3bc /tests
parenteba4197c71d152b30ddfe48e9dfbbd88f1ffd104 (diff)
Made get_indexes() consistent across backends.
Fixed #15933, #18082 -- the get_indexes() method introspection was done inconsitently depending on the backend. For example SQLite included all the columns in the table in the returned dictionary, while MySQL introspected also multicolumn indexes. All backends return now consistenly only single-column indexes. Thanks to andi for the MySQL report, and ikelly for comments on Oracle's get_indexes() changes.
Diffstat (limited to 'tests')
-rw-r--r--tests/regressiontests/introspection/models.py5
-rw-r--r--tests/regressiontests/introspection/tests.py9
2 files changed, 13 insertions, 1 deletions
diff --git a/tests/regressiontests/introspection/models.py b/tests/regressiontests/introspection/models.py
index 3b8383e601..02a8d71549 100644
--- a/tests/regressiontests/introspection/models.py
+++ b/tests/regressiontests/introspection/models.py
@@ -7,6 +7,9 @@ class Reporter(models.Model):
email = models.EmailField()
facebook_user_id = models.BigIntegerField(null=True)
+ class Meta:
+ unique_together = ('first_name', 'last_name')
+
def __unicode__(self):
return u"%s %s" % (self.first_name, self.last_name)
@@ -19,4 +22,4 @@ class Article(models.Model):
return self.headline
class Meta:
- ordering = ('headline',) \ No newline at end of file
+ ordering = ('headline',)
diff --git a/tests/regressiontests/introspection/tests.py b/tests/regressiontests/introspection/tests.py
index b425b6401d..ca58f04494 100644
--- a/tests/regressiontests/introspection/tests.py
+++ b/tests/regressiontests/introspection/tests.py
@@ -137,6 +137,15 @@ class IntrospectionTests(TestCase):
indexes = connection.introspection.get_indexes(cursor, Article._meta.db_table)
self.assertEqual(indexes['reporter_id'], {'unique': False, 'primary_key': False})
+ def test_get_indexes_multicol(self):
+ """
+ Test that multicolumn indexes are not included in the introspection
+ results.
+ """
+ cursor = connection.cursor()
+ indexes = connection.introspection.get_indexes(cursor, Reporter._meta.db_table)
+ self.assertNotIn('first_name', indexes)
+ self.assertIn('id', indexes)
def datatype(dbtype, description):
"""Helper to convert a data type into a string."""