Re: [Django] #10574: Remove unnecessary ordering in values() queries

2009-03-25 Thread Django
#10574: Remove unnecessary ordering in values() queries
--+-
  Reporter:  mtredinnick  | Owner:  mtredinnick
Status:  new  | Milestone:  1.1
 Component:  ORM aggregation  |   Version:  SVN
Resolution:   |  Keywords: 
 Stage:  Accepted | Has_patch:  0  
Needs_docs:  0|   Needs_tests:  0  
Needs_better_patch:  0|  
--+-
Comment (by mtredinnick):

 I'm going to document our way out of this one so that Django's behaviour
 is consistent (if not brilliant). We never remove ordering constraints
 internally, it's always up to the user.

-- 
Ticket URL: 
Django 
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 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
-~--~~~~--~~--~--~---



Re: [Django] #10574: Remove unnecessary ordering in values() queries

2009-03-23 Thread Django
#10574: Remove unnecessary ordering in values() queries
--+-
  Reporter:  mtredinnick  | Owner:  mtredinnick
Status:  new  | Milestone:  1.1
 Component:  ORM aggregation  |   Version:  SVN
Resolution:   |  Keywords: 
 Stage:  Accepted | Has_patch:  0  
Needs_docs:  0|   Needs_tests:  0  
Needs_better_patch:  0|  
--+-
Changes (by mtredinnick):

  * needs_better_patch:  => 0
  * needs_tests:  => 0
  * version:  => SVN
  * milestone:  => 1.1
  * needs_docs:  => 0
  * stage:  Unreviewed => Accepted

-- 
Ticket URL: 
Django 
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 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
-~--~~~~--~~--~--~---



[Django] #10574: Remove unnecessary ordering in values() queries

2009-03-20 Thread Django
#10574: Remove unnecessary ordering in values() queries
-+--
 Reporter:  mtredinnick  |   Owner:  mtredinnick
   Status:  new  |   Milestone: 
Component:  ORM aggregation  | Version: 
 Keywords:   |   Stage:  Unreviewed 
Has_patch:  0|  
-+--
 The ORM applies any ordering (such as default ordering given by
 `Meta.ordering`) all the time. For this model:
 {{{
 #!python
 class Item(models.Model):
 name = models.CharField(max_length=10)
 data = models.IntegerField()

 class Meta:
 ordering = ["name"]
 }}}

 This is redundant in `values()` queries like this:
 {{{
 #!python
 Item.objects.values("data")
 }}}

 Even worse, it leads to incorrect results in aggregate queries like this
 one:
 {{{
 #!python
 Item.objects.values("data").annotate(Count("id"))
 }}}

 Normally, that would return the number of entries for each data value.
 However, due to the ordering by name being included, we group by (data,
 name), which affects the result. The solution is to realise that the
 ordering columns aren't going to feature in the result and remove them.

 It can be worked around, once you realise the problem, although that last
 part isn't easy (it took me more than a few minutes):
 {{{
 #!python
 Items.objects.values("data").annotate(Count("id")).order_by()
 }}}

 but Django has enough information to work this out itself.

 (I'm going to put this in the aggregation category, since that's where the
 real apparent bug emerges and people will be looking there for similar
 things, I guess.)

-- 
Ticket URL: 
Django 
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 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
-~--~~~~--~~--~--~---