summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorHannes Ljungberg <hannes@5monkeys.se>2019-10-23 22:16:55 +0200
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2019-10-24 09:53:33 +0200
commit7fe09e6d41b35d5a9a03783650249723313d3793 (patch)
tree219bfad207bcedc34da3be9c7e3aa14157b2a038 /tests
parentc7f4a7da0da35feaa3c8605bfc53420ffefded4c (diff)
[2.2.x] Fixed #30903 -- Fixed migrations crash on PostgreSQL when adding Index with opclasses and ordering.
Backport of fa5f3291e7f2611d53e64ab481ebe951b0161791 from master
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 8f3c032641..4f534f0693 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):