summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMariusz Felisiak <felisiak.mariusz@gmail.com>2022-11-04 09:30:23 +0100
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2022-11-04 09:31:30 +0100
commit84a2b2e7a7d8ac0dd210bcfa299fab8c4f240aae (patch)
tree837dbc19dc51c0a7cb79e83ba6f2e666a851c215 /tests
parent018311d481d4ad949633cab1adb7677b927c8b1e (diff)
[4.1.x] Fixed #34138 -- Avoided table rebuild when adding inline m2m fields on SQLite.
Regression in 2f73e5406d54cb8945e187eff302a3a3373350be. Thanks David Wobrock for the report. Backport of 7b0e9ea53ca99de2f485ec582f3a79be34b531d4 from main
Diffstat (limited to 'tests')
-rw-r--r--tests/schema/tests.py19
1 files changed, 18 insertions, 1 deletions
diff --git a/tests/schema/tests.py b/tests/schema/tests.py
index 126c03c63c..9c891c015e 100644
--- a/tests/schema/tests.py
+++ b/tests/schema/tests.py
@@ -2112,8 +2112,25 @@ class SchemaTests(TransactionTestCase):
with self.assertRaises(DatabaseError):
self.column_classes(new_field.remote_field.through)
# Add the field
- with connection.schema_editor() as editor:
+ with CaptureQueriesContext(
+ connection
+ ) as ctx, connection.schema_editor() as editor:
editor.add_field(LocalAuthorWithM2M, new_field)
+ # Table is not rebuilt.
+ self.assertEqual(
+ len(
+ [
+ query["sql"]
+ for query in ctx.captured_queries
+ if "CREATE TABLE" in query["sql"]
+ ]
+ ),
+ 1,
+ )
+ self.assertIs(
+ any("DROP TABLE" in query["sql"] for query in ctx.captured_queries),
+ False,
+ )
# Ensure there is now an m2m table there
columns = self.column_classes(new_field.remote_field.through)
self.assertEqual(