#32461: PostgreSQL UNACCENT function not working on annotations
-------------------------------------+-------------------------------------
Reporter: Ismael | Owner: nobody
Jerez |
Type: Bug | Status: new
Component: Database | Version: 2.2
layer (models, ORM) | Keywords: annotate,
Severity: Normal | annotations, unaccent, postgresql
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
Hi!
I want to use unaccent lookup for annotated fields in a Queryset but it is
not working. This is my example:
{{{
whens = [
{
'when': Q(field=True}),
'then': Value('Yes')
},
{
'when': Q(field=False}),
'then': Value('No')
},
]
case_whens = [models.When(when['when'], then=when['then']) for when in
whens]
queryset = queryset.annotate(
"field_custom"=models.Case(
*case_whens,
output_field=models.CharField()
)
)
}}}
This work fine and the new field (field_custom) returns correct values.
But when I use unaccent lookup in a filter...
{{{
result = queryset.filter(field_custom__unaccent__icontains="és")
}}}
This gets me an empty queryset as result. If I use the same filter on
another field (non-annotated one) works fine.
Thanks you in advance,
Ismael.
P.S.: This is just an example, it has no sense but I cannot show my
original code on here.
--
Ticket URL: <https://code.djangoproject.com/ticket/32461>
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/057.0c6e17daa8e4e2aaa96795428d5f9b85%40djangoproject.com.