Author: russellm
Date: 2009-04-11 10:25:15 -0500 (Sat, 11 Apr 2009)
New Revision: 10526

Modified:
   django/trunk/django/db/models/sql/query.py
Log:
Fixed #10796 -- Corrected a pickling problem introduced by [10522]. Thanks to 
carljm for the report.

Modified: django/trunk/django/db/models/sql/query.py
===================================================================
--- django/trunk/django/db/models/sql/query.py  2009-04-11 15:13:31 UTC (rev 
10525)
+++ django/trunk/django/db/models/sql/query.py  2009-04-11 15:25:15 UTC (rev 
10526)
@@ -124,8 +124,13 @@
         obj_dict['related_select_cols'] = []
         del obj_dict['connection']
 
-        # Fields can't be pickled, so we pickle the list of field names 
instead.
-        obj_dict['select_fields'] = [f.name for f in obj_dict['select_fields']]
+        # Fields can't be pickled, so if a field list has been
+        # 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
 
     def __setstate__(self, obj_dict):
@@ -133,7 +138,10 @@
         Unpickling support.
         """
         # 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)
         # XXX: Need a better solution for this when multi-db stuff is


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to