﻿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
27257	Use the ->> operator when filtering builtin text lookups on JSONField keys	Nick Stefan	Simon Charette	"Given a model with a jsonb field, 'content', and it has a key called 'altText'.


{{{
queryset.filter(content__altText__iregex=""bob"") 

}}}

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 ?
"	Bug	closed	contrib.postgres	dev	Normal	fixed			Ready for checkin	1	0	0	0	0	0
