#31097: StringAgg And ArrayAgg with filtering in subquery generates invalid
string_agg() SQL function call
----------------------------------+------------------------------------
     Reporter:  Laurent Tramoy    |                    Owner:  (none)
         Type:  Bug               |                   Status:  new
    Component:  contrib.postgres  |                  Version:  3.0
     Severity:  Normal            |               Resolution:
     Keywords:                    |             Triage Stage:  Accepted
    Has patch:  0                 |      Needs documentation:  0
  Needs tests:  0                 |  Patch needs improvement:  0
Easy pickings:  0                 |                    UI/UX:  0
----------------------------------+------------------------------------
Changes (by Baptiste Mispelon):

 * version:  2.2 => 3.0
 * stage:  Unreviewed => Accepted


Comment:

 Reproduced on current master (ff00a053478fee06bdfb4206c6d4e079e98640ff)
 using the code in the ticket.

 Here's the prettified query reported by `--debug-sql` after the testcase
 failure:
 {{{#!sql lineno=1 marks=20
 SELECT
   "aaaaaaticket31097_book"."id",
   "aaaaaaticket31097_book"."category"
 FROM
   "aaaaaaticket31097_book"
 WHERE
   "aaaaaaticket31097_book"."id" IN (
     SELECT
       U0."id"
     FROM
       "aaaaaaticket31097_book" U0
       LEFT OUTER JOIN "aaaaaaticket31097_book_people" U1 ON (U0."id" =
 U1."book_id")
       LEFT OUTER JOIN "aaaaaaticket31097_person" U2 ON (U1."person_id" =
 U2."id")
     WHERE
       U0."id" = "aaaaaaticket31097_book"."id"
     GROUP BY
       U0."id"
     HAVING
       NOT (
         STRING_AGG(, ',') FILTER (
           WHERE
             U2."first_name"
         ) = ''
       )
   )
 }}}

-- 
Ticket URL: <https://code.djangoproject.com/ticket/31097#comment:2>
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/064.c111169b42b931eb40e021ed15d1c5de%40djangoproject.com.

Reply via email to