#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:  Unreviewed
    Has patch:  0                 |      Needs documentation:  0
  Needs tests:  0                 |  Patch needs improvement:  0
Easy pickings:  0                 |                    UI/UX:  0
----------------------------------+--------------------------------------
Description changed by Aymeric Augustin:

Old description:

> With the following model:
>
> ```
> from django.contrib.postgres.fields import JSONField
> from django.db import models
>

> class Subscription(models.Model):
>     inputs = JSONField()
> ```
>
> I'd like this query to work (assuming a inputs look like `{'first_name':
> '...'}`:
>
> ```
> Subscription.objects.filter(inputs__first_name__unaccent__icontains="...")
> ```
>
> But it fails with:
>
> ```
> django.db.utils.ProgrammingError: operator does not exist: jsonb #> text
> LINE 1: ...%' OR UPPER("subscriptions_subscription"."inputs" #>
> ARRAY['...
>                                                              ^
> HINT:  No operator matches the given name and argument type(s). You might
> need to add explicit type casts.
> ```
>
> cecef94275118dc49a1b0d89d3ca9734e2ec9776 registered a bunch of lookups
> for chaining after a key transform, but unaccent wasn't included. I
> suggest to include it as well.

New description:

 With the following model:

 {{{
 from django.contrib.postgres.fields import JSONField
 from django.db import models


 class Subscription(models.Model):
     inputs = JSONField()
 }}}

 I'd like this query to work (assuming a inputs look like `{'first_name':
 '...'}`:

 {{{
 Subscription.objects.filter(inputs__first_name__unaccent__icontains="...")
 }}}

 But it fails with:

 {{{
 django.db.utils.ProgrammingError: operator does not exist: jsonb #> text
 LINE 1: ...%' OR UPPER("subscriptions_subscription"."inputs" #> ARRAY['...
                                                              ^
 HINT:  No operator matches the given name and argument type(s). You might
 need to add explicit type casts.
 }}}

 cecef94275118dc49a1b0d89d3ca9734e2ec9776 registered a bunch of lookups for
 chaining after a key transform, but unaccent wasn't included. I suggest to
 include it as well.

--

--
Ticket URL: <https://code.djangoproject.com/ticket/27824#comment:1>
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.05e9da294023df9eed221bc1b83400e0%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to