mirror of
https://github.com/django/django.git
synced 2025-08-04 02:48:35 +00:00
Fixed #30961 -- Fixed spaces in columns list SQL generated for indexes.
This commit is contained in:
parent
d5af43c8d1
commit
6d590bcf1f
2 changed files with 29 additions and 3 deletions
|
@ -83,6 +83,14 @@ class SchemaIndexesTests(TestCase):
|
|||
str(index.create_sql(Article, editor)),
|
||||
)
|
||||
|
||||
def test_descending_columns_list_sql(self):
|
||||
index = Index(fields=['-headline'], name='whitespace_idx')
|
||||
editor = connection.schema_editor()
|
||||
self.assertIn(
|
||||
'(%s DESC)' % editor.quote_name('headline'),
|
||||
str(index.create_sql(Article, editor)),
|
||||
)
|
||||
|
||||
|
||||
@skipIf(connection.vendor == 'postgresql', 'opclasses are PostgreSQL only')
|
||||
class SchemaIndexesNotPostgreSQLTests(TransactionTestCase):
|
||||
|
@ -231,6 +239,18 @@ class SchemaIndexesPostgreSQLTests(TransactionTestCase):
|
|||
cursor.execute(self.get_opclass_query % indexname)
|
||||
self.assertCountEqual(cursor.fetchall(), [('text_pattern_ops', indexname)])
|
||||
|
||||
def test_ops_class_columns_lists_sql(self):
|
||||
index = Index(
|
||||
fields=['headline'],
|
||||
name='whitespace_idx',
|
||||
opclasses=['text_pattern_ops'],
|
||||
)
|
||||
with connection.schema_editor() as editor:
|
||||
self.assertIn(
|
||||
'(%s text_pattern_ops)' % editor.quote_name('headline'),
|
||||
str(index.create_sql(Article, editor)),
|
||||
)
|
||||
|
||||
def test_ops_class_descending_columns_list_sql(self):
|
||||
index = Index(
|
||||
fields=['-headline'],
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue