--
Ticket URL: <https://code.djangoproject.com/ticket/24887>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* stage: Unreviewed => Accepted
--
Ticket URL: <https://code.djangoproject.com/ticket/24887#comment:1>
* status: new => assigned
* owner: nobody => gchp
--
Ticket URL: <https://code.djangoproject.com/ticket/24887#comment:2>
Comment (by akaariai):
This should be one-line change to django/db/models/aggregates, remove the
line that does the assert for len(self.source_expressions) and things
should work.
--
Ticket URL: <https://code.djangoproject.com/ticket/24887#comment:3>
* has_patch: 0 => 1
Comment:
PR here: https://github.com/django/django/pull/4767
--
Ticket URL: <https://code.djangoproject.com/ticket/24887#comment:4>
Comment (by coldmind):
I think it because
https://github.com/django/django/blob/3e9b5bfd9c3e16c968278f7d050f52739690eb29/django/db/models/aggregates.py#L21
is using only first expression, so it will be confusing to allow passing
more
--
Ticket URL: <https://code.djangoproject.com/ticket/24887#comment:5>
Comment (by charettes):
Does `len(self.source_expressions) == (c.source_expressions)` in all
cases? If that's the case maybe we should loop over all
`c.source_expressions` to test for `.contains_aggregate and not
summarize`.
--
Ticket URL: <https://code.djangoproject.com/ticket/24887#comment:6>
Comment (by jarshwah):
Yes, a loop will do. We'll also need to fail if an aggregate is provided
multiple source_expressions but no alias. See
https://github.com/django/django/blob/3e9b5bfd9c3e16c968278f7d050f52739690eb29/django/db/models/aggregates.py#L22
and
https://github.com/django/django/blob/3e9b5bfd9c3e16c968278f7d050f52739690eb29/django/db/models/aggregates.py#L34
--
Ticket URL: <https://code.djangoproject.com/ticket/24887#comment:7>
Comment (by gchp):
I've updated the PR to loop over source_expressions. Wondering how I can
test the new behavour - can anyone give some pointers on how I might make
source_expressions have more than one element?
--
Ticket URL: <https://code.djangoproject.com/ticket/24887#comment:8>
* needs_tests: 0 => 1
--
Ticket URL: <https://code.djangoproject.com/ticket/24887#comment:9>
* needs_tests: 1 => 0
Comment:
Just updated the PR with a test
--
Ticket URL: <https://code.djangoproject.com/ticket/24887#comment:10>
* needs_better_patch: 0 => 1
--
Ticket URL: <https://code.djangoproject.com/ticket/24887#comment:11>
* needs_better_patch: 1 => 0
Comment:
I've extended @ghcp's PR with code that handles default_alias and a
recursive contains_aggregate. https://github.com/django/django/pull/4900
--
Ticket URL: <https://code.djangoproject.com/ticket/24887#comment:12>
* status: assigned => closed
* resolution: => fixed
Comment:
In [changeset:"4a66a69239c493c05b322815b18c605cd4c96e7c" 4a66a692]:
{{{
#!CommitTicketReference repository=""
revision="4a66a69239c493c05b322815b18c605cd4c96e7c"
Fixed #24887 -- Removed one-arg limit from models.aggregate
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/24887#comment:13>
Comment (by Simon Charette <charette.s@…>):
In [changeset:"160969d97080b53e9113cadcecc27c26a51881e8" 160969d]:
{{{
#!CommitTicketReference repository=""
revision="160969d97080b53e9113cadcecc27c26a51881e8"
Refs #24887 -- Stopped mutating a test expression during as_sql().
Also defined an explicit output_field as it was mixing an expression with
an
IntegerField() with one with a DecimalField().
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/24887#comment:14>