diff options
| author | Hannes Ljungberg <hannes@5monkeys.se> | 2019-11-07 21:26:08 +0100 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2019-11-08 08:52:47 +0100 |
| commit | 6d590bcf1ff1d66990d03f8ee288e18110bdd995 (patch) | |
| tree | f262b13fcb381e77cabe889c4bfc18d5e5af2b13 /tests | |
| parent | d5af43c8d1de7bc21e6e01f31e711c02a5059a5a (diff) | |
Fixed #30961 -- Fixed spaces in columns list SQL generated for indexes.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/indexes/tests.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/indexes/tests.py b/tests/indexes/tests.py index 799146d6a8..04ab036139 100644 --- a/tests/indexes/tests.py +++ b/tests/indexes/tests.py @@ -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'], |
