Kaydet (Commit) d63ac5b5 authored tarafından Baptiste Mispelon's avatar Baptiste Mispelon

Fixed #23492 -- Restored F.__deepcopy__.

This reverts commit 3a660351.
A regression test was also added.
üst ed782123
......@@ -145,6 +145,11 @@ class F(ExpressionNode):
super(F, self).__init__(None, None, False)
self.name = name
def __deepcopy__(self, memodict):
obj = super(F, self).__deepcopy__(memodict)
obj.name = self.name
return obj
def prepare(self, evaluator, query, allow_joins):
return evaluator.prepare_leaf(self, query, allow_joins)
......
from __future__ import unicode_literals
from copy import deepcopy
import datetime
from django.core.exceptions import FieldError
......@@ -287,6 +288,14 @@ class ExpressionsTests(TestCase):
)
self.assertEqual(str(qs.query).count('JOIN'), 2)
def test_F_object_deepcopy(self):
"""
Make sure F objects can be deepcopied (#23492)
"""
f = F("foo")
g = deepcopy(f)
self.assertEqual(f.name, g.name)
class ExpressionsNumericTests(TestCase):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment