Re: Subquery join support

2020-04-15 Thread Andre Terra
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.

Re: Subquery join support

2020-04-15 Thread Alexandr Tatarinov
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

Re: Subquery join support

2020-04-12 Thread Alexandr Tatarinov
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',

Re: Subquery join support

2020-04-07 Thread Alexandr Tatarinov
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

Re: Subquery join support

2020-04-06 Thread schinckel
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

Re: Subquery join support

2020-04-06 Thread Alexandr Tatarinov
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 >

RE: Subquery join support

2020-04-06 Thread Matthew Pava
they have never made it in. Perhaps someone with more knowledge on that matter can help. From: django-developers@googlegroups.com On Behalf Of Alexandr Tatarinov Sent: Monday, April 6, 2020 3:22 AM To: Django developers (Contributions to Django itself) Subject: Subquery join support Hello folks

Subquery join support

2020-04-06 Thread Alexandr Tatarinov
Hello folks, Following the discussion https://groups.google.com/forum/#!topic/django-developers/b370mxfKCHg, I would like to suggest adding the ability to join QuerySet with a subquery clause to Django. The benefits are pretty much described and discussed in the linked topic, the only one I