This is an initial draft/ RFC commit that provides support merging queries with CTEs on both sides.
Initial support is for (union, difference, and difference) operators | and & are not as yet supported by may be possible to implement as a union wrapped in a CTE to allow Django to continue to apply filters an other ops.
move all CTEs to the first or master query in the set.
renames the CTEs if there are naming conflicts conflicts. (I'm not 100% happy with this )
More work will be needed to improve..
the limited test coverage. Any help or real example here appreciated.
identification of identical CTEs (atm we use == to test for equality i.e. same object. This is correct but not means two identical CTE but not the same object will both be added, this means that the resultant SQL is less optimal )
I dont like renaming the CTE but as this may affect raw CTEs and raw sql_extras
This is an initial draft/ RFC commit that provides support merging queries with CTEs on both sides. Initial support is for (union, difference, and difference) operators | and & are not as yet supported by may be possible to implement as a union wrapped in a CTE to allow Django to continue to apply filters an other ops.
ie allowing
combined_ctequery = cte_query1.union(cte_query2, cte_query3)
Basic premise is to:
More work will be needed to improve..
This may solve #32