MCPcopy
hub / github.com/django/django / test_remove_field

Method test_remove_field

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

Source from the content-addressed store, hash-verified

1086 AddAutoFieldModel.objects.create(name="test")
1087
1088 def test_remove_field(self):
1089 with connection.schema_editor() as editor:
1090 editor.create_model(Author)
1091 with CaptureQueriesContext(connection) as ctx:
1092 editor.remove_field(Author, Author._meta.get_field("name"))
1093 columns = self.column_classes(Author)
1094 self.assertNotIn("name", columns)
1095 if getattr(connection.features, "can_alter_table_drop_column", True):
1096 # Table is not rebuilt.
1097 self.assertIs(
1098 any("CREATE TABLE" in query["sql"] for query in ctx.captured_queries),
1099 False,
1100 )
1101 self.assertIs(
1102 any("DROP TABLE" in query["sql"] for query in ctx.captured_queries),
1103 False,
1104 )
1105
1106 def test_remove_indexed_field(self):
1107 with connection.schema_editor() as editor:

Callers

nothing calls this directly

Calls 6

column_classesMethod · 0.95
schema_editorMethod · 0.80
create_modelMethod · 0.45
remove_fieldMethod · 0.45
get_fieldMethod · 0.45

Tested by

no test coverage detected