﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
32461	PostgreSQL UNACCENT function not working on annotations	Ismael Jerez	nobody	"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."	Bug	closed	contrib.postgres	2.2	Normal	needsinfo	annotate, annotations, unaccent, postgresql		Unreviewed	0	0	0	0	0	0
