mirror of
https://github.com/django/django.git
synced 2024-12-22 17:16:24 +00:00
Fixed #23492 -- Restored F.__deepcopy__.
This reverts commit 3a66035107
.
A regression test was also added.
This commit is contained in:
parent
ed7821231b
commit
d63ac5b595
@ -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)
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
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):
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user