mirror of
https://github.com/django/django.git
synced 2025-10-23 21:59:11 +00:00
Fixed #24109 -- Allowed RunSQL and RunPython operations to be elided.
Thanks to Markus Holtermann and Tim Graham for their review.
This commit is contained in:
@@ -1532,6 +1532,10 @@ class OperationTests(OperationTestBase):
|
||||
self.assertEqual(definition[0], "RunSQL")
|
||||
self.assertEqual(definition[1], [])
|
||||
self.assertEqual(sorted(definition[2]), ["reverse_sql", "sql", "state_operations"])
|
||||
# And elidable reduction
|
||||
self.assertIs(False, operation.reduce(operation, []))
|
||||
elidable_operation = migrations.RunSQL('SELECT 1 FROM void;', elidable=True)
|
||||
self.assertEqual(elidable_operation.reduce(operation, []), [operation])
|
||||
|
||||
def test_run_sql_params(self):
|
||||
"""
|
||||
@@ -1705,6 +1709,10 @@ class OperationTests(OperationTestBase):
|
||||
operation.database_forwards("test_runpython", editor, project_state, new_state)
|
||||
self.assertEqual(project_state.apps.get_model("test_runpython", "Pony").objects.count(), 6)
|
||||
self.assertEqual(project_state.apps.get_model("test_runpython", "ShetlandPony").objects.count(), 2)
|
||||
# And elidable reduction
|
||||
self.assertIs(False, operation.reduce(operation, []))
|
||||
elidable_operation = migrations.RunPython(inner_method, elidable=True)
|
||||
self.assertEqual(elidable_operation.reduce(operation, []), [operation])
|
||||
|
||||
def test_run_python_atomic(self):
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user