mirror of
https://github.com/django/django.git
synced 2025-10-31 09:41:08 +00:00
Fixed #24831 -- Fixed pickling queryset with prefetch_related() after deleting objects.
This commit is contained in:
committed by
Tim Graham
parent
e1e6399c2c
commit
2913d6b77d
@@ -119,6 +119,20 @@ class PickleabilityTestCase(TestCase):
|
||||
groups = pickle.loads(pickle.dumps(groups))
|
||||
self.assertQuerysetEqual(groups, [g], lambda x: x)
|
||||
|
||||
def test_pickle_prefetch_related_with_m2m_and_objects_deletion(self):
|
||||
"""
|
||||
#24831 -- Cached properties on ManyToOneRel created in QuerySet.delete()
|
||||
caused subsequent QuerySet pickling to fail.
|
||||
"""
|
||||
g = Group.objects.create(name='foo')
|
||||
m2m = M2MModel.objects.create()
|
||||
m2m.groups.add(g)
|
||||
Group.objects.all().delete()
|
||||
|
||||
m2ms = M2MModel.objects.prefetch_related('groups')
|
||||
m2ms = pickle.loads(pickle.dumps(m2ms))
|
||||
self.assertQuerysetEqual(m2ms, [m2m], lambda x: x)
|
||||
|
||||
def test_missing_django_version_unpickling(self):
|
||||
"""
|
||||
#21430 -- Verifies a warning is raised for querysets that are
|
||||
|
||||
Reference in New Issue
Block a user