mirror of
https://github.com/django/django.git
synced 2025-06-05 03:29:12 +00:00
Fixed #10796 -- Corrected a pickling problem introduced by [10522]. Thanks to carljm for the report.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@10526 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
945b89e177
commit
4a4d3e2133
@ -124,8 +124,13 @@ class BaseQuery(object):
|
|||||||
obj_dict['related_select_cols'] = []
|
obj_dict['related_select_cols'] = []
|
||||||
del obj_dict['connection']
|
del obj_dict['connection']
|
||||||
|
|
||||||
# Fields can't be pickled, so we pickle the list of field names instead.
|
# Fields can't be pickled, so if a field list has been
|
||||||
obj_dict['select_fields'] = [f.name for f in obj_dict['select_fields']]
|
# specified, we pickle the list of field names instead.
|
||||||
|
# None is also a possible value; that can pass as-is
|
||||||
|
obj_dict['select_fields'] = [
|
||||||
|
f is not None and f.name or None
|
||||||
|
for f in obj_dict['select_fields']
|
||||||
|
]
|
||||||
return obj_dict
|
return obj_dict
|
||||||
|
|
||||||
def __setstate__(self, obj_dict):
|
def __setstate__(self, obj_dict):
|
||||||
@ -133,7 +138,10 @@ class BaseQuery(object):
|
|||||||
Unpickling support.
|
Unpickling support.
|
||||||
"""
|
"""
|
||||||
# Rebuild list of field instances
|
# Rebuild list of field instances
|
||||||
obj_dict['select_fields'] = [obj_dict['model']._meta.get_field(name) for name in obj_dict['select_fields']]
|
obj_dict['select_fields'] = [
|
||||||
|
name is not None and obj_dict['model']._meta.get_field(name) or None
|
||||||
|
for name in obj_dict['select_fields']
|
||||||
|
]
|
||||||
|
|
||||||
self.__dict__.update(obj_dict)
|
self.__dict__.update(obj_dict)
|
||||||
# XXX: Need a better solution for this when multi-db stuff is
|
# XXX: Need a better solution for this when multi-db stuff is
|
||||||
|
Loading…
x
Reference in New Issue
Block a user