#30209: Union with group by don't generate correct Subquery -------------------------------------+------------------------------------- Reporter: Nikolas | Owner: nobody Type: Bug | Status: new Component: Database layer | Version: master (models, ORM) | Severity: Normal | Resolution: Keywords: union, group by | Triage Stage: Accepted Has patch: 0 | Needs documentation: 1 Needs tests: 0 | Patch needs improvement: 0 Easy pickings: 0 | UI/UX: 0 -------------------------------------+-------------------------------------
Comment (by TKdka): Replying to [comment:5 Simon Charette]: > > I'm planning to make this a sub query pushdown as suggested. FYI, this is my first contribution to the code base, so suggestions and feedback would be most appreciated. > > TKdka, not to discourage you but this is certainly going to be a hard first contribution as the ORM doesn't have any formalized API to perform such pushdown yet. If that can provide you any guidance the most similar code I can think of is in `django.db.models.sql.Query.get_aggregation`. After looking into this, you are completely right that it's a big endeavor. The difficult part is that the query needs to be manipulated even after the annotate call, which is significantly different from the aggregate example. Therefore, I'll submit a small patch that raises an exception when this is attempted. I'm not sure what exception class should be used here. TypeError? Thoughts? -- Ticket URL: <https://code.djangoproject.com/ticket/30209#comment:7> 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 django-updates+unsubscr...@googlegroups.com. To post to this group, send email to django-updates@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/069.864562f0230eea168053ec554d01db38%40djangoproject.com. For more options, visit https://groups.google.com/d/optout.