diff options
author | Rustam Kashapov <hardtechnik91@gmail.com> | 2016-05-15 12:53:16 +0300 |
---|---|---|
committer | Tim Graham <timograham@gmail.com> | 2016-06-02 13:48:35 -0400 |
commit | df8412d2e5c95fe8c8238ebde8e0dbb68fe2ec1d (patch) | |
tree | 58495dcfbed508cc58456b44e32bf97cbbeb46a1 /django/contrib/postgres/aggregates/general.py | |
parent | 149ace94dfc10504a0e69462c7737f5ce05340a4 (diff) | |
download | django-df8412d2e5c95fe8c8238ebde8e0dbb68fe2ec1d.tar.gz |
Fixed #26617 -- Added distinct argument to contrib.postgres's StringAgg.
Diffstat (limited to 'django/contrib/postgres/aggregates/general.py')
-rw-r--r-- | django/contrib/postgres/aggregates/general.py | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/django/contrib/postgres/aggregates/general.py b/django/contrib/postgres/aggregates/general.py index 1dda69c449..6ff6727bd4 100644 --- a/django/contrib/postgres/aggregates/general.py +++ b/django/contrib/postgres/aggregates/general.py @@ -32,10 +32,11 @@ class BoolOr(Aggregate): class StringAgg(Aggregate): function = 'STRING_AGG' - template = "%(function)s(%(expressions)s, '%(delimiter)s')" + template = "%(function)s(%(distinct)s%(expressions)s, '%(delimiter)s')" - def __init__(self, expression, delimiter, **extra): - super(StringAgg, self).__init__(expression, delimiter=delimiter, **extra) + def __init__(self, expression, delimiter, distinct=False, **extra): + distinct = 'DISTINCT ' if distinct else '' + super(StringAgg, self).__init__(expression, delimiter=delimiter, distinct=distinct, **extra) def convert_value(self, value, expression, connection, context): if not value: |