#35146: Add support for annotate after union
-------------------------------------+-------------------------------------
Reporter: Alexandru | Owner: nobody
Chirila |
Type: New | Status: new
feature |
Component: Database | Version:
layer (models, ORM) |
Severity: Normal | Keywords:
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
This is currently not supported, and the ORM rightly throws an error
whenever you attempt to do so. I believe it would be beneficial to have
such support allowing a query like this be generated
{{{#!sql
SELECT release_date AS release_date,
MAX(price) AS max_price,
MIN(price) AS min_price
FROM (SELECT release_date, price
FROM products_1
WHERE foo = 'bar'
UNION
SELECT release_date, price
FROM products_2
WHERE foo = 'bar') AS products_subquery
GROUP BY release_date
}}}
Which might look something like this in the ORM
{{{#!python
query1 = Products1.objects.filter(foo="bar")
query2 = Products2.objects.filter(foo="bar")
query1.union(query2).values("release_date").annotate(
min_price=Min("price"), max_price=Max("price")
)
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/35146>
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 view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/0107018d461d3835-61256a93-2a4a-4c55-80b4-12cfeed6df80-000000%40eu-central-1.amazonses.com.