diff options
| author | Anssi Kääriäinen <akaariai@gmail.com> | 2013-05-21 11:06:49 +0300 |
|---|---|---|
| committer | Anssi Kääriäinen <akaariai@gmail.com> | 2013-05-21 11:45:24 +0300 |
| commit | bac187c0d8e829fb3ca2ca82965eabbcbcb6ddd5 (patch) | |
| tree | 68c928525813836104b4587cb217c45efec9f735 /django/db/models/sql/query.py | |
| parent | 63cab03f6ddd9faa5a770ae08791b2a70aa0a578 (diff) | |
[1.5.x] Fixed prefetch_related + pickle regressions
There were a couple of regressions related to field pickling. The
regressions were introduced by QuerySet._known_related_objects caching.
The regressions aren't present in master, the fix was likely in
f403653cf146384946e5c879ad2a351768ebc226.
Fixed #20157, fixed #20257. Also made QuerySets with model=None
picklable.
Diffstat (limited to 'django/db/models/sql/query.py')
| -rw-r--r-- | django/db/models/sql/query.py | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/django/db/models/sql/query.py b/django/db/models/sql/query.py index 7368fed24c..390444d799 100644 --- a/django/db/models/sql/query.py +++ b/django/db/models/sql/query.py @@ -208,12 +208,17 @@ class Query(object): Unpickling support. """ # Rebuild list of field instances - opts = obj_dict['model']._meta - obj_dict['select_fields'] = [ - name is not None and opts.get_field(name) or None - for name in obj_dict['select_fields'] - ] - + model = obj_dict['model'] + if model is None: + # if model is None the queryset should be emptyqs. So the + # select_fields do not matter. + obj_dict['select_fields'] = [] + else: + opts = model._meta + obj_dict['select_fields'] = [ + name is not None and opts.get_field(name) or None + for name in obj_dict['select_fields'] + ] self.__dict__.update(obj_dict) def prepare(self): |
