MCPcopy
hub / github.com/django/django / test_func_index

Method test_func_index

tests/schema/tests.py:4181–4198  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

4179
4180 @skipUnlessDBFeature("supports_expression_indexes")
4181 def test_func_index(self):
4182 with connection.schema_editor() as editor:
4183 editor.create_model(Author)
4184 index = Index(Lower("name").desc(), name="func_lower_idx")
4185 # Add index.
4186 with connection.schema_editor() as editor:
4187 editor.add_index(Author, index)
4188 sql = index.create_sql(Author, editor)
4189 table = Author._meta.db_table
4190 if connection.features.supports_index_column_ordering:
4191 self.assertIndexOrder(table, index.name, ["DESC"])
4192 # SQL contains a database function.
4193 self.assertIs(sql.references_column(table, "name"), True)
4194 self.assertIn("LOWER(%s)" % editor.quote_name("name"), str(sql))
4195 # Remove index.
4196 with connection.schema_editor() as editor:
4197 editor.remove_index(Author, index)
4198 self.assertNotIn(index.name, self.get_constraints(table))
4199
4200 @skipUnlessDBFeature("supports_expression_indexes")
4201 def test_func_index_f(self):

Callers

nothing calls this directly

Calls 12

create_sqlMethod · 0.95
assertIndexOrderMethod · 0.95
get_constraintsMethod · 0.95
IndexClass · 0.90
LowerClass · 0.90
schema_editorMethod · 0.80
create_modelMethod · 0.45
descMethod · 0.45
add_indexMethod · 0.45
references_columnMethod · 0.45
quote_nameMethod · 0.45
remove_indexMethod · 0.45

Tested by

no test coverage detected