Re: [Django] #36890: Allow providing distinct=True to StringAgg on SQLite by specifying the default delimiter (was: StringAgg doesn't allow DISTINCT in sqlite3 while native GROUP_CONCAT does)

1 view
Skip to first unread message

Django

unread,
Jan 30, 2026, 2:51:42 PM (6 days ago) Jan 30
to django-...@googlegroups.com
#36890: Allow providing distinct=True to StringAgg on SQLite by specifying the
default delimiter
-------------------------------------+-------------------------------------
Reporter: AJ Slater | Owner: (none)
Type: New feature | Status: new
Component: Database layer | Version: 6.0
(models, ORM) |
Severity: Normal | Resolution:
Keywords: Aggregate, sqlite3, | Triage Stage: Accepted
StringAgg |
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Jacob Walls):

* keywords: Aggregate, sqlite3 => Aggregate, sqlite3, StringAgg
* stage: Unreviewed => Accepted
* summary:
StringAgg doesn't allow DISTINCT in sqlite3 while native GROUP_CONCAT
does
=>
Allow providing distinct=True to StringAgg on SQLite by specifying the
default delimiter
* type: Uncategorized => New feature

Comment:

Seems reasonable, we should be able to drop the delimiter if
`self.delimiter.value == models.Value(",")` similar to what the MySQL code
path does:

{{{#!py
# Drop the delimiter from the source expressions.
c.source_expressions = c.source_expressions[:-1]
}}}

That should evade the check:
{{{#!py
if (
self.distinct
and not
connection.features.supports_aggregate_distinct_multiple_argument
and len(super().get_source_expressions()) > 1
):
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/36890#comment:3>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
Reply all
Reply to author
Forward
0 new messages