Skip to content

Commit 1d4c52c

Browse files
SnippyCodesjacobtylerwalls
authored andcommitted
Fixed #36893 -- Serialized elidable kwarg for RunSQL and RunPython operations.
1 parent 5798f4b commit 1d4c52c

2 files changed

Lines changed: 12 additions & 0 deletions

File tree

django/db/migrations/operations/special.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,8 @@ def deconstruct(self):
9393
kwargs["state_operations"] = self.state_operations
9494
if self.hints:
9595
kwargs["hints"] = self.hints
96+
if self.elidable:
97+
kwargs["elidable"] = self.elidable
9698
return (self.__class__.__qualname__, [], kwargs)
9799

98100
@property
@@ -173,6 +175,8 @@ def deconstruct(self):
173175
kwargs["atomic"] = self.atomic
174176
if self.hints:
175177
kwargs["hints"] = self.hints
178+
if self.elidable:
179+
kwargs["elidable"] = self.elidable
176180
return (self.__class__.__qualname__, [], kwargs)
177181

178182
@property

tests/migrations/test_operations.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5543,6 +5543,10 @@ def test_run_sql(self):
55435543
elidable_operation = migrations.RunSQL("SELECT 1 FROM void;", elidable=True)
55445544
self.assertEqual(elidable_operation.reduce(operation, []), [operation])
55455545

5546+
# Test elidable deconstruction
5547+
definition = elidable_operation.deconstruct()
5548+
self.assertIs(definition[2]["elidable"], True)
5549+
55465550
def test_run_sql_params(self):
55475551
"""
55485552
#23426 - RunSQL should accept parameters.
@@ -5796,6 +5800,10 @@ def create_shetlandponies(models, schema_editor):
57965800
elidable_operation = migrations.RunPython(inner_method, elidable=True)
57975801
self.assertEqual(elidable_operation.reduce(operation, []), [operation])
57985802

5803+
# Test elidable deconstruction
5804+
definition = elidable_operation.deconstruct()
5805+
self.assertIs(definition[2]["elidable"], True)
5806+
57995807
def test_run_python_invalid_reverse_code(self):
58005808
msg = "RunPython must be supplied with callable arguments"
58015809
with self.assertRaisesMessage(ValueError, msg):

0 commit comments

Comments
 (0)