summaryrefslogtreecommitdiff
path: root/tests/indexes
diff options
context:
space:
mode:
authorAnubhav Joshi <anubhav9042@gmail.com>2014-03-02 00:36:15 +0530
committerTim Graham <timograham@gmail.com>2014-03-01 15:44:42 -0500
commitbb2ca9fe6cdd490526b44b30f207c8f743bfaa84 (patch)
tree8e448c5f136ad0160d062bc65e23bc107cee656c /tests/indexes
parent3273bd7b254680a5b241e2fdbc3196956b2b44e8 (diff)
Fixed #22172 -- Allowed index_together to be a single list (rather than list of lists)..
Thanks EmilStenstrom for the suggestion.
Diffstat (limited to 'tests/indexes')
-rw-r--r--tests/indexes/models.py8
-rw-r--r--tests/indexes/tests.py8
2 files changed, 15 insertions, 1 deletions
diff --git a/tests/indexes/models.py b/tests/indexes/models.py
index e38eb005db..064a099b40 100644
--- a/tests/indexes/models.py
+++ b/tests/indexes/models.py
@@ -12,6 +12,14 @@ class Article(models.Model):
]
+# Model for index_together being used only with single list
+class IndexTogetherSingleList(models.Model):
+ headline = models.CharField(max_length=100)
+ pub_date = models.DateTimeField()
+
+ class Meta:
+ index_together = ["headline", "pub_date"]
+
# Indexing a TextField on Oracle or MySQL results in index creation error.
if connection.vendor == 'postgresql':
class IndexedArticle(models.Model):
diff --git a/tests/indexes/tests.py b/tests/indexes/tests.py
index 605fe9037c..da93b31d87 100644
--- a/tests/indexes/tests.py
+++ b/tests/indexes/tests.py
@@ -4,7 +4,7 @@ from django.core.management.color import no_style
from django.db import connections, DEFAULT_DB_ALIAS
from django.test import TestCase
-from .models import Article
+from .models import Article, IndexTogetherSingleList
class IndexesTests(TestCase):
@@ -13,6 +13,12 @@ class IndexesTests(TestCase):
index_sql = connection.creation.sql_indexes_for_model(Article, no_style())
self.assertEqual(len(index_sql), 1)
+ def test_index_together_single_list(self):
+ # Test for using index_together with a single list (#22172)
+ connection = connections[DEFAULT_DB_ALIAS]
+ index_sql = connection.creation.sql_indexes_for_model(IndexTogetherSingleList, no_style())
+ self.assertEqual(len(index_sql), 1)
+
@skipUnless(connections[DEFAULT_DB_ALIAS].vendor == 'postgresql',
"This is a postgresql-specific issue")
def test_postgresql_text_indexes(self):