#34079: Excessive parentheses when generating a query
-------------------------------------+-------------------------------------
     Reporter:  Lelikov              |                    Owner:  Aman
                                     |  Pandey
         Type:  Bug                  |                   Status:  closed
    Component:  Database layer       |                  Version:  4.1
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:  invalid
     Keywords:                       |             Triage Stage:
                                     |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

 * cc: Peter Lithammer, Simon Charette (added)
 * resolution:   => invalid
 * status:  assigned => closed
 * component:  Uncategorized => Database layer (models, ORM)


Comment:

 Thanks for the report, however this behavior was intentionally changed in
 170b006ce82b0ecf26dc088f832538b747ca0115 (see also #32673) and we cannot
 revert it without reintroducing regressions.

 As far as I'm aware,`ANY` requires `ARRAY` or a subquery on the right-hand
 side,  so I'm not sure how this could work for you 🤔 Nevertheless you can
 always creating a custom lookup, the following example works for me:
 {{{#!python
 class Any(Lookup):
     def as_sql(self, compiler, connection):
         lhs, lhs_params = self.process_lhs(compiler, connection)
         rhs, rhs_params = self.process_rhs(compiler, connection)
         params = (*lhs_params, *rhs_params)
         return "%s = ANY(%s)" % (lhs, rhs), params

 > Note.objects.filter(Any(F("note"),
 Subquery(Annotation.objects.values("name"))))
 }}}

-- 
Ticket URL: <https://code.djangoproject.com/ticket/34079#comment:5>
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/01070183cbdf174f-a6d26523-e267-4d33-a47d-31cce9ed6411-000000%40eu-central-1.amazonses.com.

Reply via email to