#28038: Cast regression in PostgresSQL using built-in lookups
-------------------------------------+-------------------------------------
               Reporter:  Peter J.   |          Owner:  nobody
  Farrell                            |
                   Type:  Bug        |         Status:  new
              Component:  Database   |        Version:  1.11
  layer (models, ORM)                |       Keywords:  postgres postgresql
               Severity:  Normal     |  array_agg
           Triage Stage:             |      Has patch:  0
  Unreviewed                         |
    Needs documentation:  0          |    Needs tests:  0
Patch needs improvement:  0          |  Easy pickings:  0
                  UI/UX:  0          |
-------------------------------------+-------------------------------------
 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
 }}}

--
Ticket URL: <https://code.djangoproject.com/ticket/28038>
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/055.a6c09660f169b55ac099f498954dfb5c%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to