summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMariusz Felisiak <felisiak.mariusz@gmail.com>2022-02-11 22:21:58 +0100
committerGitHub <noreply@github.com>2022-02-11 22:21:58 +0100
commit3702819227fd0cdd9b581cd99e11d1561d51cbeb (patch)
treedbb187f9d7c3c34ac647b4ddc614c8e67b813a89 /tests
parentd113b5a837f726d1c638d76c4e88445e6cd59fd5 (diff)
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.
Diffstat (limited to 'tests')
-rw-r--r--tests/schema/tests.py18
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