Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #10796 -- Corrected a pickling problem introduced by [10522]. T…

…hanks to carljm for the report.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@10526 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 4a4d3e213316ea39a0f8d596c9c0d3dfba8ce495 1 parent 945b89e
Russell Keith-Magee authored April 11, 2009

Showing 1 changed file with 11 additions and 3 deletions. Show diff stats Hide diff stats

  1. 14  django/db/models/sql/query.py
14  django/db/models/sql/query.py
@@ -124,8 +124,13 @@ def __getstate__(self):
124 124
         obj_dict['related_select_cols'] = []
125 125
         del obj_dict['connection']
126 126
 
127  
-        # Fields can't be pickled, so we pickle the list of field names instead.
128  
-        obj_dict['select_fields'] = [f.name for f in obj_dict['select_fields']]
  127
+        # Fields can't be pickled, so if a field list has been
  128
+        # specified, we pickle the list of field names instead.
  129
+        # None is also a possible value; that can pass as-is
  130
+        obj_dict['select_fields'] = [
  131
+            f is not None and f.name or None
  132
+            for f in obj_dict['select_fields']
  133
+        ]
129 134
         return obj_dict
130 135
 
131 136
     def __setstate__(self, obj_dict):
@@ -133,7 +138,10 @@ def __setstate__(self, obj_dict):
133 138
         Unpickling support.
134 139
         """
135 140
         # Rebuild list of field instances
136  
-        obj_dict['select_fields'] = [obj_dict['model']._meta.get_field(name) for name in obj_dict['select_fields']]
  141
+        obj_dict['select_fields'] = [
  142
+            name is not None and obj_dict['model']._meta.get_field(name) or None
  143
+            for name in obj_dict['select_fields']
  144
+        ]
137 145
 
138 146
         self.__dict__.update(obj_dict)
139 147
         # XXX: Need a better solution for this when multi-db stuff is

0 notes on commit 4a4d3e2

Please sign in to comment.
Something went wrong with that request. Please try again.