﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
35146	Add support for annotate after union	Alexandru Chirila	nobody	"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"")
)
}}}
"	New feature	closed	Database layer (models, ORM)		Normal	duplicate		Alexandru Chirila Stephen	Unreviewed	0	0	0	0	0	0
