#21604: Embed raw queries as subqueries when used with an __in filter
-------------------------------------+-------------------------------------
     Reporter:  alex@…               |                    Owner:  nobody
         Type:  New feature          |                   Status:  new
    Component:  Database layer       |                  Version:  master
  (models, ORM)                      |               Resolution:
     Severity:  Normal               |             Triage Stage:  Accepted
     Keywords:                       |      Needs documentation:  0
    Has patch:  1                    |  Patch needs improvement:  1
  Needs tests:  0                    |                    UI/UX:  0
Easy pickings:  0                    |
-------------------------------------+-------------------------------------
Changes (by akaariai):

 * needs_better_patch:  0 => 1


Comment:

 Sorry for not responding to this ticket sooner.

 I think the patch is a bit too invasive for this ticket. We only need
 support for `somefield__in=rawqs`. It would be hopefully possible to just
 alter the way how the SQL is generated when used in an `in` lookup. In
 particular there shouldn't be any need

 I wonder if it would be better to just add support for
 `qs.filter(somefield__in=RawQuery(sql_str, params))` (and also do the same
 for other lookup types if at all possible). This would be a lot easier to
 support (actually, this will be likely extremely easy to do after #14030).
 Of course, this doesn't allow one to use an existing raw query.

 If this could be implemented with just wrapping the query in subquery when
 used from `__in` lookup, then I think supporting `somefield__in=rawqs`
 directly is OK. If not, then lets focus on adding support for
 `somefield__in=RawQuery(sql_str, params)`. In other words, the current
 patch seems too complicated for the added feature.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/21604#comment:2>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/074.eed172b419b38bddd9a9dfa80e91f538%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to