#27824: Cannot chain unaccent transform with key lookup in Postgres JSON field
----------------------------------+------------------------------------
     Reporter:  Aymeric Augustin  |                    Owner:  (none)
         Type:  New feature       |                   Status:  new
    Component:  contrib.postgres  |                  Version:  1.10
     Severity:  Normal            |               Resolution:
     Keywords:                    |             Triage Stage:  Accepted
    Has patch:  0                 |      Needs documentation:  0
  Needs tests:  0                 |  Patch needs improvement:  0
Easy pickings:  0                 |                    UI/UX:  0
----------------------------------+------------------------------------
Changes (by Tim Graham):

 * stage:  Unreviewed => Accepted


Comment:

 Django 1.11 (since the commit you mentioned) isn't crashing anymore but I
 don't think the query is correct. This test addition to
 `postgres_tests/test_json.py` isn't working:
 
`self.assertTrue(JSONModel.objects.filter(field__foo__unaccent__icontains='bár').exists())`.
 It generates this SQL:

 {{{ #!sql
 SELECT "postgres_tests_jsonmodel"."id",
 "postgres_tests_jsonmodel"."field",
 "postgres_tests_jsonmodel"."field_custom"
 FROM "postgres_tests_jsonmodel"
 WHERE UPPER(("postgres_tests_jsonmodel"."field" #>> ['foo', 'unaccent']))
 LIKE UPPER(%bár%)
 }}}
 By the way, the workaround as translated to Django's test suite isn't
 working for me (tested on 1.11 and 1.10):
 {{{
 >>> JSONModel.objects.annotate(
     _first_name=RawSQL("(field -> 'foo')::text", [],
 output_field=TextField()),
 ).filter(
     _first_name__unaccent__icontains='bár',
 )
 ...
 FieldError: Unsupported lookup 'unaccent' for TextField or join on the
 field not permitted.

--
Ticket URL: <https://code.djangoproject.com/ticket/27824#comment:3>
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 post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/067.536090d5ae3e49c92a788b9ff7cacf3f%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to