﻿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
28038	Cast regression in PostgresSQL using built-in lookups	Peter J. Farrell	Simon Charette <charette.s@…>	"The following query works in Django 1.10 or less but fails on Django 1.11 with the following error message:

{{{
function upper(character varying[]) does not exist... No function matches the given name and argument types. You might need to add explicit type casts.
}}}

{{{
query = self.filter(
    category=category
).annotate(
    arm_types=ArrayAgg('assets__arm_type')
).filter(
    arm_types__icontains=arm_type
)
}}}

The change is that the filter using the icontains no longer casts to ::text. It appears this is regression that is caused by this commit:

https://github.com/django/django/commit/658f1e81a7ea29acf30bbf8f61ffec2beff24639#diff-8e3817dff3483fe3eaecb84d56803e32

The SQL generated from Django 1.10 looks like this (wheres 1.11 no longer includes the ::text cast):

{{{
UPPER(ARRAY_AGG(""asset_furnitureasset"".""arm_type"")::text) LIKE
UPPER('%Without Arms%') ORDER BY ""asset_furniture"".""make_model"" ASC
}}}"	Bug	closed	Database layer (models, ORM)	1.11	Release blocker	fixed	postgres postgresql array_agg		Ready for checkin	1	0	0	0	0	0
