diff options
Diffstat (limited to 'tests/schema')
| -rw-r--r-- | tests/schema/tests.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/schema/tests.py b/tests/schema/tests.py index 208421eb64..37f2946006 100644 --- a/tests/schema/tests.py +++ b/tests/schema/tests.py @@ -789,6 +789,24 @@ class SchemaTests(TransactionTestCase): # Introspection treats BLOBs as TextFields self.assertEqual(columns["bits"][0], "TextField") + def test_remove_field(self): + with connection.schema_editor() as editor: + editor.create_model(Author) + with CaptureQueriesContext(connection) as ctx: + editor.remove_field(Author, Author._meta.get_field("name")) + columns = self.column_classes(Author) + self.assertNotIn("name", columns) + if getattr(connection.features, "can_alter_table_drop_column", True): + # Table is not rebuilt. + self.assertIs( + any("CREATE TABLE" in query["sql"] for query in ctx.captured_queries), + False, + ) + self.assertIs( + any("DROP TABLE" in query["sql"] for query in ctx.captured_queries), + False, + ) + def test_alter(self): """ Tests simple altering of fields |
