MCPcopy
hub / github.com/django/django / test_func_index_f

Method test_func_index_f

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

Source from the content-addressed store, hash-verified

4199
4200 @skipUnlessDBFeature("supports_expression_indexes")
4201 def test_func_index_f(self):
4202 with connection.schema_editor() as editor:
4203 editor.create_model(Tag)
4204 index = Index("slug", F("title").desc(), name="func_f_idx")
4205 # Add index.
4206 with connection.schema_editor() as editor:
4207 editor.add_index(Tag, index)
4208 sql = index.create_sql(Tag, editor)
4209 table = Tag._meta.db_table
4210 self.assertIn(index.name, self.get_constraints(table))
4211 if connection.features.supports_index_column_ordering:
4212 self.assertIndexOrder(Tag._meta.db_table, index.name, ["ASC", "DESC"])
4213 # SQL contains columns.
4214 self.assertIs(sql.references_column(table, "slug"), True)
4215 self.assertIs(sql.references_column(table, "title"), True)
4216 # Remove index.
4217 with connection.schema_editor() as editor:
4218 editor.remove_index(Tag, index)
4219 self.assertNotIn(index.name, self.get_constraints(table))
4220
4221 @skipUnlessDBFeature("supports_expression_indexes")
4222 def test_func_index_lookups(self):

Callers

nothing calls this directly

Calls 11

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

Tested by

no test coverage detected