SQL:
{{{
..."app_model"."filed" = (ANY("app_user"."notification_email_types")))
}}}
Error:
{{{
syntax error at or near "ANY"
}}}
The reason for the code change in version 4.0. The excessive parentheses
around the function ANY
django/db/models/lookups.py
{{{
if sql and sql[0] != "(":
sql = "(%s)" % sql
}}}
In version 3.2 everything worked correctly
--
Ticket URL: <https://code.djangoproject.com/ticket/34079>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* type: Uncategorized => Bug
--
Ticket URL: <https://code.djangoproject.com/ticket/34079#comment:1>
Comment (by Giebisch):
Im pretty sure I had a similar error a few weeks ago. I can't test right
now, but if the error still persists, I will be happy to look into it :)
--
Ticket URL: <https://code.djangoproject.com/ticket/34079#comment:2>
Comment (by Aman Pandey):
i would like to look into it
--
Ticket URL: <https://code.djangoproject.com/ticket/34079#comment:3>
* owner: nobody => Aman Pandey
* status: new => assigned
--
Ticket URL: <https://code.djangoproject.com/ticket/34079#comment:4>
* 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>