#29731: Type conversion should be possible with OuterRef
-------------------------------------+-------------------------------------
               Reporter:  tienne-B   |          Owner:  nobody
                   Type:  Bug        |         Status:  new
              Component:  Database   |        Version:  2.1
  layer (models, ORM)                |       Keywords:  postgresql, sql,
               Severity:  Normal     |  json, outerref
           Triage Stage:             |      Has patch:  0
  Unreviewed                         |
    Needs documentation:  0          |    Needs tests:  0
Patch needs improvement:  0          |  Easy pickings:  0
                  UI/UX:  0          |
-------------------------------------+-------------------------------------
 With the query:

 {{{
 subquery = SentMessageRecord.objects.filter(tournament=self.tournament,
 email=OuterRef('email'), context__key=OuterRef('url_key'),
 event=SentMessageRecord.EVENT_TYPE_URL)
 people = self.tournament.participants.filter(url_key__isnull=False,
 
email__isnull=False).exclude(email__exact="").annotate(already_sent=Exists(subquery)).filter(already_sent=already_sent)
 }}}

 where `url_key` is a `CharField` and `context` is a `JsonField` (using
 Postgres), the `__key` is a string that corresponds to `url_key`. However,
 I get the error:

 {{{
 django.db.utils.ProgrammingError: operator does not exist: jsonb =
 character varying
 LINE 1: ...tmessagerecord" U0 WHERE ((U0."context" -> 'key') = ("partic...
                                                              ^
 HINT:  No operator matches the given name and argument type(s). You might
 need to add explicit type casts.
 }}}

 Wrapping the `OuterRef` with `str()` prevents the error, but seems to be
 ineffective.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/29731>
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 
https://groups.google.com/d/msgid/django-updates/051.54a55c1932663bca1a250cce77172db1%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to