#3732: inconsistent values('col1', 'col2').distinct().count()
----------------------------------------------------+-----------------------
Reporter:  David S. <[EMAIL PROTECTED]>  |       Owner:  adrian          
  Status:  new                                      |   Component:  Database 
wrapper
 Version:  SVN                                      |    Keywords:              
    
   Stage:  Unreviewed                               |   Has_patch:  1           
    
----------------------------------------------------+-----------------------
 A ValueQuerySet with selected columns and using distinct returns a count
 that is accurate only if _result_cache exists--because it can get its
 len().
 If _result_cache does not exists then the SQL to fetch to count is
 inaccurate because it relies on the PK rather than the selected columns.
 
 For instance:
 {{{
 #!python
 >>> cs = Course.objects.filter(subject__code="ACC",
 course_num=207).values('subject', 'course_num')
 >>> cs
 [{'course_num': '207', 'subject': 'ACC'}, {'course_num': '207', 'subject':
 'ACC'}]
 >>> cs.count()
 2
 >>> cs.distinct().count()
 2L
 >>> csdistinct = cs.distinct()
 >>> csdistinct.count()
 2L
 >>> csdistinct
 [{'course_num': '207', 'subject': 'ACC'}]
 >>> csdistinct.count()
 1
 }}}
 The attached patch has been tested and works on Postgres and Oracle and,
 though the documentation explicitly says it should work, it seems to fail
 with SQLite (at least testing in its shell.)

-- 
Ticket URL: <http://code.djangoproject.com/ticket/3732>
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