diff options
| author | Hannes Ljungberg <hannes@5monkeys.se> | 2019-10-23 22:16:55 +0200 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2019-10-24 09:33:14 +0200 |
| commit | fa5f3291e7f2611d53e64ab481ebe951b0161791 (patch) | |
| tree | 2b3e7dc860d5d80df16d79122549469b957019be /tests/indexes | |
| parent | 2a54ce72f95977fefe796e99c7bbf6cd366927f9 (diff) | |
Fixed #30903 -- Fixed migrations crash on PostgreSQL when adding Index with opclasses and ordering.
Diffstat (limited to 'tests/indexes')
| -rw-r--r-- | tests/indexes/tests.py | 27 |
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): |
