mirror of
https://github.com/django/django.git
synced 2025-10-23 21:59:11 +00:00
Refs #32502 -- Avoided table rebuild when removing fields on SQLite 3.35.5+.
ALTER TABLE ... DROP COLUMN was introduced in SQLite 3.35+ however a data corruption issue was fixed in SQLite 3.35.5.
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user