Changes between Initial Version and Version 1 of Ticket #27332


Ignore:
Timestamp:
Oct 10, 2016, 4:42:45 PM (8 years ago)
Author:
MikiSoft
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #27332 – Description

    initial v1  
    1212}}}
    1313
    14 Can't be translated to equivalent Django ORM expression even if using `extra()` command, because there isn't anywhere a possibility to set additional arguments on `JOIN` clauses. And when I'm using  `filter(Q(argument) | ...)` it happens to always push all arguments to `WHERE` clause, which just causes a performance hit. I wish there was some parameter which would determine the destination of the argument, whether it has to go to the (last) `JOIN` clause, or to be put in `WHERE` (which goes by default). Also, I'm not able to comprehend how to perform correctly `LEFT JOIN` so in the end I have made some jumbled up expression which is completely inefficient (as it executes two queries, but it's the only way to do the same from above and get `QuerySet` in return):
     14Can't be translated to the **equivalent** Django ORM expression even if using `extra()` command, because there isn't anywhere a possibility to set additional arguments on `JOIN` clauses. And when I'm using  `filter(Q(argument) | ...)` it happens to always push all arguments to `WHERE` clause, which just causes a performance hit. I wish there was some parameter which would determine the destination of the argument, whether it has to go to the (last) `JOIN` clause, or to be put in `WHERE` (which goes by default). Also, I'm not able to comprehend how to perform correctly `LEFT JOIN` so in the end I have made some jumbled up expression which is completely inefficient (as it executes two queries, but it's the only way to do the same from above and get `QuerySet` in return):
    1515
    1616{{{
    17 from django.db.models import Q, Coalesce
     17from django.db.models import Q
     18from django.db.models.functions import Coalesce
    1819
    19 Event.objects.filter(Q(pk__in=Like.objects.filter(person__pk‌​‌​=1, content_type=17).prefetch_related('content_object').values_l‌​‌​ist('object_id', flat=True)) | Q(business__manager=1)).order_by(Coalesce('likes__date', 'when').desc())
     20Event.objects.filter(Q(pk__in=Like.objects.filter(person__pk‌​‌​=1, content_type__pk=17).prefetch_related('content_object').values_l‌​‌​ist('object_id', flat=True)) | Q(business__manager=1)).order_by(Coalesce('likes__date', 'when').desc())
    2021}}}
    2122
    22 I'm filing this issue because some (or many?) people like me desperately need output in a form of a `QuerySet` because of the pagination and many other things `RawQuerySet` doesn't support, so using `raw()` isn't definitely an option in my case. Django has left me out of choice.
     23I'm filing this issue because some (or probably many) people like me desperately need output in a form of a `QuerySet` because of the pagination and many other things `RawQuerySet` doesn't support, so using `raw()` isn't definitely an option in my case. Django has left me out of choice.
Back to Top