--
Ticket URL: <http://code.djangoproject.com/ticket/16025>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0
Comment:
I'm aware wrote "Average" here instead of "Avg" -- I meant "Avg". The
rest of the bug still applies, I was trying to make an example of the
error that was effecting my application using different models (because my
application's models are rather complex).
--
Ticket URL: <http://code.djangoproject.com/ticket/16025#comment:1>
* component: Database layer (models, ORM) => ORM aggregation
* stage: Unreviewed => Accepted
Comment:
Does your Food model have any `Meta.ordering` model option or does the
queryset have a `order_by()` call somewhere?
--
Ticket URL: <https://code.djangoproject.com/ticket/16025#comment:2>
Comment (by micolous):
In the example application I developed it doesn't (the only difference is
I've implemented `__unicode__`, but in the application I'm actually
writing it does.
Both ways give the same (erroneous) result.
--
Ticket URL: <https://code.djangoproject.com/ticket/16025#comment:3>
--
--
Ticket URL: <https://code.djangoproject.com/ticket/16025#comment:4>
* ui_ux: => 0
Comment:
This bug is also experienced here:
http://stackoverflow.com/questions/4093910/django-aggregates-sums-in-
postgresql-dont-use-distinct-is-this-a-bug
--
Ticket URL: <https://code.djangoproject.com/ticket/16025#comment:5>
* version: 1.3 => 1.6
Comment:
Still there in 1.6 :-(
--
Ticket URL: <https://code.djangoproject.com/ticket/16025#comment:7>
* status: new => assigned
* owner: nobody => mikalai
--
Ticket URL: <https://code.djangoproject.com/ticket/16025#comment:8>
* owner: mikalai =>
* status: assigned => new
--
Ticket URL: <https://code.djangoproject.com/ticket/16025#comment:9>
* status: new => closed
* resolution: => fixed
Comment:
I'm not sure when this got fixed but I can confirm that the `DISTINCT` is
now applied to the subquery aggregated over by the expression provided in
the `aggregate` call and not on the outer query which was effectively
useless. I suspect that #23875 fixed it by moving the
[https://github.com/django/django/commit/c7fd9b242d2d63406f1de6cc3204e35aaa025233
#diff-0edd853580d56db07e4020728d59e193R339 distinct special casing] from
the `get_count` method to the `get_aggregation` one.
--
Ticket URL: <https://code.djangoproject.com/ticket/16025#comment:10>