summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/indexes/tests.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/indexes/tests.py b/tests/indexes/tests.py
index 2272cadc4f..588feaddff 100644
--- a/tests/indexes/tests.py
+++ b/tests/indexes/tests.py
@@ -196,6 +196,33 @@ class SchemaIndexesPostgreSQLTests(TransactionTestCase):
cursor.execute(self.get_opclass_query % indexname)
self.assertCountEqual(cursor.fetchall(), [('text_pattern_ops', indexname)])
+ def test_ops_class_descending(self):
+ indexname = 'test_ops_class_ordered'
+ index = Index(
+ name=indexname,
+ fields=['-body'],
+ opclasses=['text_pattern_ops'],
+ )
+ with connection.schema_editor() as editor:
+ editor.add_index(IndexedArticle2, index)
+ with editor.connection.cursor() as cursor:
+ cursor.execute(self.get_opclass_query % indexname)
+ self.assertCountEqual(cursor.fetchall(), [('text_pattern_ops', indexname)])
+
+ def test_ops_class_descending_partial(self):
+ indexname = 'test_ops_class_ordered_partial'
+ index = Index(
+ name=indexname,
+ fields=['-body'],
+ opclasses=['text_pattern_ops'],
+ condition=Q(headline__contains='China'),
+ )
+ with connection.schema_editor() as editor:
+ editor.add_index(IndexedArticle2, index)
+ with editor.connection.cursor() as cursor:
+ cursor.execute(self.get_opclass_query % indexname)
+ self.assertCountEqual(cursor.fetchall(), [('text_pattern_ops', indexname)])
+
@skipUnless(connection.vendor == 'mysql', 'MySQL tests')
class SchemaIndexesMySQLTests(TransactionTestCase):