mirror of
https://github.com/django/django.git
synced 2026-02-09 02:49:25 +08:00
Fixed #36893 -- Serialized elidable kwarg for RunSQL and RunPython operations.
This commit is contained in:
@@ -93,6 +93,8 @@ class RunSQL(Operation):
|
|||||||
kwargs["state_operations"] = self.state_operations
|
kwargs["state_operations"] = self.state_operations
|
||||||
if self.hints:
|
if self.hints:
|
||||||
kwargs["hints"] = self.hints
|
kwargs["hints"] = self.hints
|
||||||
|
if self.elidable:
|
||||||
|
kwargs["elidable"] = self.elidable
|
||||||
return (self.__class__.__qualname__, [], kwargs)
|
return (self.__class__.__qualname__, [], kwargs)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@@ -173,6 +175,8 @@ class RunPython(Operation):
|
|||||||
kwargs["atomic"] = self.atomic
|
kwargs["atomic"] = self.atomic
|
||||||
if self.hints:
|
if self.hints:
|
||||||
kwargs["hints"] = self.hints
|
kwargs["hints"] = self.hints
|
||||||
|
if self.elidable:
|
||||||
|
kwargs["elidable"] = self.elidable
|
||||||
return (self.__class__.__qualname__, [], kwargs)
|
return (self.__class__.__qualname__, [], kwargs)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
|||||||
@@ -5543,6 +5543,10 @@ class OperationTests(OperationTestBase):
|
|||||||
elidable_operation = migrations.RunSQL("SELECT 1 FROM void;", elidable=True)
|
elidable_operation = migrations.RunSQL("SELECT 1 FROM void;", elidable=True)
|
||||||
self.assertEqual(elidable_operation.reduce(operation, []), [operation])
|
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):
|
def test_run_sql_params(self):
|
||||||
"""
|
"""
|
||||||
#23426 - RunSQL should accept parameters.
|
#23426 - RunSQL should accept parameters.
|
||||||
@@ -5796,6 +5800,10 @@ class OperationTests(OperationTestBase):
|
|||||||
elidable_operation = migrations.RunPython(inner_method, elidable=True)
|
elidable_operation = migrations.RunPython(inner_method, elidable=True)
|
||||||
self.assertEqual(elidable_operation.reduce(operation, []), [operation])
|
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):
|
def test_run_python_invalid_reverse_code(self):
|
||||||
msg = "RunPython must be supplied with callable arguments"
|
msg = "RunPython must be supplied with callable arguments"
|
||||||
with self.assertRaisesMessage(ValueError, msg):
|
with self.assertRaisesMessage(ValueError, msg):
|
||||||
|
|||||||
Reference in New Issue
Block a user