#36890: StringAgg doesn't allow DISTINCT in sqlite3 while native GROUP_CONCAT 
does
-------------------------------------+-------------------------------------
     Reporter:  AJ Slater            |                    Owner:  (none)
         Type:  Uncategorized        |                   Status:  new
    Component:  Database layer       |                  Version:  6.0
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:
     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
-------------------------------------+-------------------------------------
Comment (by Simon Charette):

 I'm not sure I understand your report here.

 The code you provided states that `" "` is the default separator for
 `GROUP_CONCAT` but [https://sqlite.org/lang_aggfunc.html#group_concat the
 documentation says otherwise].

 > The `group_concat()` function returns a string which is the
 concatenation of all non-`NULL` values of X. If parameter Y is present
 then it is used as the separator between instances of X. **A comma (",")
 is used as the separator if Y is omitted**.

 which I was able to confirm with

 {{{
 SQLite version 3.37.0 2021-12-09 01:34:53
 Enter ".help" for usage hints.
 Connected to a transient in-memory database.
 Use ".open FILENAME" to reopen on a persistent database.
 sqlite> CREATE TABLE ticket_36890 (value text);
 sqlite> INSERT INTO ticket_36890 (value) VALUES ('foo'), ('bar'), ('foo');
 sqlite> SELECT GROUP_CONCAT(value), GROUP_CONCAT(DISTINCT value) FROM
 ticket_36890;
 foo,bar,foo|foo,bar
 }}}

 which that we could support `StringAgg("field", Value(","),
 distinct=True)` on SQLite but not `StringAgg("field", Value(" "),
 distinct=True)`
-- 
Ticket URL: <https://code.djangoproject.com/ticket/36890#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 [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/django-updates/0107019c0a991352-338240d8-cd05-467b-b291-6c428ff27c94-000000%40eu-central-1.amazonses.com.

Reply via email to