mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
Fixed #34138 -- Avoided table rebuild when adding inline m2m fields on SQLite.
Regression in 2f73e5406d.
Thanks David Wobrock for the report.
This commit is contained in:
@@ -2200,8 +2200,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(
|
||||
|
||||
Reference in New Issue
Block a user