#10060: Multiple table annotation failure
-------------------------------------+-------------------------------------
Reporter: svsharma@… | Owner: (none)
Type: Bug | Status: new
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Simon Charette):
Since this ticket has more exposure I wanted to mention that #28296 ought
to fix this by allowing a `subquery` argument to be passed to aggregate
functions.
If it was to be implemented the original report queryset could be made to
return the correct results easily
{{{#!python
Branch.objects.annotate(
total=Sum('center__client__loan__amount'),
repaid=Sum('center__client__loan__payment_schedule__payments__principal',
subquery=True),
)
}}}
Once this lands the ORM should be in a position to detect and warn about
or even deprecate multiple cross joined annotations.
Given the current existing logic with the `Subquery` expression it
shouldn't be too hard for someone with basic expression knowledge about
the ORM to implement a patch if anyone is interested in contributing.
--
Ticket URL: <https://code.djangoproject.com/ticket/10060#comment:66>
Django <https://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 unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/081.c1cbc64fdb4175b04978a4ba23b2a4e2%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.