﻿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
29731	Type conversion should be possible with OuterRef	Étienne Beaulé	nobody	"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."	Bug	closed	Database layer (models, ORM)	2.1	Normal	invalid	postgresql, sql, json, outerref		Unreviewed	0	0	0	0	0	0
