summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSnippyCodes <aaryanparik124@gmail.com>2026-01-31 13:43:17 +0530
committerJacob Walls <jacobtylerwalls@gmail.com>2026-02-02 21:05:44 -0500
commit1d4c52c8bf62cc912e5099e86ff229b69ce9d227 (patch)
tree5f8bf5670494320ac1dfd5c0ab567418da417133
parent5798f4bb1750f68d3bfbaa75020db7fa02b4db15 (diff)
Fixed #36893 -- Serialized elidable kwarg for RunSQL and RunPython operations.
-rw-r--r--django/db/migrations/operations/special.py4
-rw-r--r--tests/migrations/test_operations.py8
2 files changed, 12 insertions, 0 deletions
diff --git a/django/db/migrations/operations/special.py b/django/db/migrations/operations/special.py
index 0700023325..311271483e 100644
--- a/django/db/migrations/operations/special.py
+++ b/django/db/migrations/operations/special.py
@@ -93,6 +93,8 @@ class RunSQL(Operation):
kwargs["state_operations"] = self.state_operations
if self.hints:
kwargs["hints"] = self.hints
+ if self.elidable:
+ kwargs["elidable"] = self.elidable
return (self.__class__.__qualname__, [], kwargs)
@property
@@ -173,6 +175,8 @@ class RunPython(Operation):
kwargs["atomic"] = self.atomic
if self.hints:
kwargs["hints"] = self.hints
+ if self.elidable:
+ kwargs["elidable"] = self.elidable
return (self.__class__.__qualname__, [], kwargs)
@property
diff --git a/tests/migrations/test_operations.py b/tests/migrations/test_operations.py
index e859b62a10..90c22bc73b 100644
--- a/tests/migrations/test_operations.py
+++ b/tests/migrations/test_operations.py
@@ -5543,6 +5543,10 @@ class OperationTests(OperationTestBase):
elidable_operation = migrations.RunSQL("SELECT 1 FROM void;", elidable=True)
self.assertEqual(elidable_operation.reduce(operation, []), [operation])
+ # Test elidable deconstruction
+ definition = elidable_operation.deconstruct()
+ self.assertIs(definition[2]["elidable"], True)
+
def test_run_sql_params(self):
"""
#23426 - RunSQL should accept parameters.
@@ -5796,6 +5800,10 @@ class OperationTests(OperationTestBase):
elidable_operation = migrations.RunPython(inner_method, elidable=True)
self.assertEqual(elidable_operation.reduce(operation, []), [operation])
+ # Test elidable deconstruction
+ definition = elidable_operation.deconstruct()
+ self.assertIs(definition[2]["elidable"], True)
+
def test_run_python_invalid_reverse_code(self):
msg = "RunPython must be supplied with callable arguments"
with self.assertRaisesMessage(ValueError, msg):