#36890: StringAgg doesn't allow DISTINCT in sqlite3 while native GROUP_CONCAT 
does
-------------------------------------+-------------------------------------
     Reporter:  AJ Slater            |                     Type:
                                     |  Uncategorized
       Status:  new                  |                Component:  Database
                                     |  layer (models, ORM)
      Version:  6.0                  |                 Severity:  Normal
     Keywords:  Aggregate, sqlite3   |             Triage Stage:
                                     |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
 Attempting to use the new generic StringAgg with distinct=True raises
 exceptions because any Aggregate with multiple parameters cannot be
 distinct with an sqlite3 connection. Running StringAgg without distinct
 produces many duplicate entries aggregated together.

 However this Aggregate runs fine under sqlite3, allows distinct and does
 not produce duplicates.

 {{{
 class GroupConcat(Aggregate):
     """Sqlite3 GROUP_CONCAT."""

     # Defaults to " " separator which is all I need for now.

     allow_distinct = True
     allow_order_by = True
     function = "GROUP_CONCAT"
     name = "GroupConcat"

     def __init__(self, *args, **kwargs):
         """output_field is set in the constructor."""
         super().__init__(*args, output_field=CharField(), **kwargs)
 }}}

 It occurs to me that this may happen because `delimiter` can be an
 expression. If delimiter is submitted as some invariant like Value() it
 would be nice to escape this limitation.
-- 
Ticket URL: <https://code.djangoproject.com/ticket/36890>
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 view this discussion visit 
https://groups.google.com/d/msgid/django-updates/0107019c073e17c3-46ee87ae-27b8-4d03-87d5-6ad00b51b93b-000000%40eu-central-1.amazonses.com.

Reply via email to