mirror of
https://github.com/django/django.git
synced 2025-06-05 11:39:13 +00:00
Refs #30961 -- Added tests for columns list SQL generated for indexes.
This commit is contained in:
parent
58c1acb1d6
commit
d5af43c8d1
@ -75,6 +75,14 @@ class SchemaIndexesTests(TestCase):
|
|||||||
index_sql = connection.schema_editor()._model_indexes_sql(IndexTogetherSingleList)
|
index_sql = connection.schema_editor()._model_indexes_sql(IndexTogetherSingleList)
|
||||||
self.assertEqual(len(index_sql), 1)
|
self.assertEqual(len(index_sql), 1)
|
||||||
|
|
||||||
|
def test_columns_list_sql(self):
|
||||||
|
index = Index(fields=['headline'], name='whitespace_idx')
|
||||||
|
editor = connection.schema_editor()
|
||||||
|
self.assertIn(
|
||||||
|
'(%s)' % editor.quote_name('headline'),
|
||||||
|
str(index.create_sql(Article, editor)),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@skipIf(connection.vendor == 'postgresql', 'opclasses are PostgreSQL only')
|
@skipIf(connection.vendor == 'postgresql', 'opclasses are PostgreSQL only')
|
||||||
class SchemaIndexesNotPostgreSQLTests(TransactionTestCase):
|
class SchemaIndexesNotPostgreSQLTests(TransactionTestCase):
|
||||||
@ -223,6 +231,18 @@ class SchemaIndexesPostgreSQLTests(TransactionTestCase):
|
|||||||
cursor.execute(self.get_opclass_query % indexname)
|
cursor.execute(self.get_opclass_query % indexname)
|
||||||
self.assertCountEqual(cursor.fetchall(), [('text_pattern_ops', indexname)])
|
self.assertCountEqual(cursor.fetchall(), [('text_pattern_ops', indexname)])
|
||||||
|
|
||||||
|
def test_ops_class_descending_columns_list_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 DESC)' % editor.quote_name('headline'),
|
||||||
|
str(index.create_sql(Article, editor)),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@skipUnless(connection.vendor == 'mysql', 'MySQL tests')
|
@skipUnless(connection.vendor == 'mysql', 'MySQL tests')
|
||||||
class SchemaIndexesMySQLTests(TransactionTestCase):
|
class SchemaIndexesMySQLTests(TransactionTestCase):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user