Thanks, Alexandr, for your effort in addressing what I personally consider
a much needed feature in the ORM. I gave your PR a try and noticed that
evaluating the same Product.objects.annotate line below twice in a row
returns two different SQL queries, the second of which results in an error.
This has not received a lot of feedback so far, so I think some code can
help. I am not sure what is the next steps; as I've understood, we need
some kind of consensus to open a ticket.
Please, don't hesitate to express your opinion on the feature and the API,
as well as the implementation to m
Hello everyone.
So far, I've managed to implement joins via Subquery and OuterRef with some
caveats.
To begin with, the API looks like this
Product.objects.create(name='Pizza', country='USA', type='FOOD')
Tax.objects.create(name='USA Food Tax', amount=10, product_country='USA',
product_type='FO
Thanks, folks, that's a very valuable insight.
I really love the idea of resolving *OuterRef* via .*join()*, it may help
overcome problems I had with reusing *Subquery*.
However, I believe *Subquery* exists apart from *QuerySet* for a reason -
to separate responsibilities, so should we mix respo
Great work on this, Alexandr. I've been thinking a lot about doing joins in
Django to subqueries. As you point out, when you are doing several subquery
annotations of the same subquery, just with different columns, that can
really hurt performance. Currently, I've been recommending doing a JSON
Accidentally removed gist, new one is here
https://gist.github.com/tatarinov1997/068fe786366401ed640dcbbbe5d959e4
On Monday, 6 April 2020 16:34:55 UTC+3, Alexandr Tatarinov wrote:
>
> Hello folks,
>
> Following the discussion
> https://groups.google.com/forum/#!topic/django-developers/b370mxfKCH
It is my opinion that the Subquery object that already exists in Django should
act as a CTE.
There is a ticket for this feature already:
https://code.djangoproject.com/ticket/28919
I have noticed that several developers have proposed several different patches
for CTEs, but I do not know why they