#27257: JSONB regex and iregex
     Reporter:  Nick Stefan                   |      Owner:  nobody
         Type:  Uncategorized                 |     Status:  new
    Component:  Database layer (models, ORM)  |    Version:  1.9
     Severity:  Normal                        |   Keywords:  QuerySet.extra
 Triage Stage:  Unreviewed                    |  Has patch:  0
Easy pickings:  1                             |      UI/UX:  0
 Given a model with a jsonb field, 'content', and it has a key called



 creates this SQL

 "content" -> 'altText'::text ~* 'bob'

 Which creates a type error

 ERROR:  operator does not exist: jsonb ~* unknown at character 2792
 postgres    | HINT:  No operator matches the given name and argument
 type(s). You might need to add explicit type casts.

 SQL actually needed is

 content ->> altText ~* 'bob'

 So I had to use:

 queryset.extra(where=['content ->> %s ~* %s'], params=['altText', 'bob'])

 Is this something to be filed under QuerySet.extra or is this more of a
 bug just with JSONField ?

Ticket URL: <https://code.djangoproject.com/ticket/27257>
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 django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
For more options, visit https://groups.google.com/d/optout.

Reply via email to