Fixed #29330 -- Fixed crash when pickling BaseExpression.
Regression in cfff2af02b
.
This commit is contained in:
parent
1d5d4867f4
commit
60156750f6
|
@ -153,6 +153,11 @@ class BaseExpression:
|
||||||
if output_field is not None:
|
if output_field is not None:
|
||||||
self.output_field = output_field
|
self.output_field = output_field
|
||||||
|
|
||||||
|
def __getstate__(self):
|
||||||
|
state = self.__dict__.copy()
|
||||||
|
state.pop('convert_value', None)
|
||||||
|
return state
|
||||||
|
|
||||||
def get_db_converters(self, connection):
|
def get_db_converters(self, connection):
|
||||||
return (
|
return (
|
||||||
[]
|
[]
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import datetime
|
import datetime
|
||||||
|
import pickle
|
||||||
import unittest
|
import unittest
|
||||||
import uuid
|
import uuid
|
||||||
from copy import deepcopy
|
from copy import deepcopy
|
||||||
|
@ -585,6 +586,11 @@ class BasicExpressionsTests(TestCase):
|
||||||
outer = Company.objects.filter(pk__in=Subquery(inner.values('pk')))
|
outer = Company.objects.filter(pk__in=Subquery(inner.values('pk')))
|
||||||
self.assertEqual(outer.get().name, 'Test GmbH')
|
self.assertEqual(outer.get().name, 'Test GmbH')
|
||||||
|
|
||||||
|
def test_pickle_expression(self):
|
||||||
|
expr = Value(1, output_field=models.IntegerField())
|
||||||
|
expr.convert_value # populate cached property
|
||||||
|
self.assertEqual(pickle.loads(pickle.dumps(expr)), expr)
|
||||||
|
|
||||||
|
|
||||||
class IterableLookupInnerExpressionsTests(TestCase):
|
class IterableLookupInnerExpressionsTests(TestCase):
|
||||||
@classmethod
|
@classmethod
|
||||||
|
|
Loading…
Reference in New Issue