mirror of
https://github.com/django/django.git
synced 2025-08-03 18:38:50 +00:00
Fixed #30903 -- Fixed migrations crash on PostgreSQL when adding Index with opclasses and ordering.
This commit is contained in:
parent
2a54ce72f9
commit
fa5f3291e7
4 changed files with 38 additions and 5 deletions
|
@ -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):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue