#8484: Caching QuerySet with extra(select) causes AttributeError
---------------------------+------------------------------------------------
 Reporter:  ckelly         |       Owner:  nobody    
   Status:  new            |   Milestone:  1.0       
Component:  Uncategorized  |     Version:  SVN       
 Keywords:                 |       Stage:  Unreviewed
Has_patch:  0              |  
---------------------------+------------------------------------------------
 I have a queryset that contains an extra() call with a select parameter
 containing a "straight" SQL call - no in place variables, etc.

 when I attempt to cache this result and then subsequently retrieve this
 object from said cache, I get an "'SortedDict' object has no attribute
 'keyOrder'" attribute error

 {{{
 >>> qs = RevisionableModel.objects.extra(select={"rm_count": "SELECT
 COUNT(*) from extra_regress_revisionablemodel"})
 >>> cache.set("extra_test", qs)
 >>> new_qs = cache.get("extra_test")
 }}}

 I'm using a file-based cache in this scenario, but was also able to
 recreate it with a db table cache.

 Traceback is as follows:
 {{{
 exception raised:
     Traceback (most recent call last):
       File "/usr/local/lib/python2.5/site-
 packages/django/test/_doctest.py", line 1267, in __run
         compileflags, 1) in test.globs
       File "<doctest extra_test.models.__test__.API_TESTS[27]>", line 1,
 in <module>
         new_qs = cache.get("extra_test")
       File "/usr/local/lib/python2.5/site-
 packages/django/core/cache/backends/filebased.py", line 50, in get
         return pickle.load(f)
       File "/usr/local/lib/python2.5/site-
 packages/django/utils/datastructures.py", line 76, in __setitem__
         if key not in self.keyOrder:
     AttributeError: 'SortedDict' object has no attribute 'keyOrder'
 }}}

 It looks like it has to do with Pickling, but I attempted to do a quick
 pickle/ unpickle on the QS, to no avail:
 {{{
 new_qs = pickle.loads(pickle.dumps(qs))
 }}}

 This is a regression introduced in Changeset 8426

 I have attached the models.py file, which is a modified version of the
 tests/regressiontests/extra_regress/models.py (rev 8463) with the
 additional test discussed above.

-- 
Ticket URL: <http://code.djangoproject.com/ticket/8484>
Django Code <http://code.djangoproject.com/>
The web framework for perfectionists with deadlines
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to