summaryrefslogtreecommitdiff
path: root/django/contrib/postgres/aggregates/general.py
diff options
context:
space:
mode:
Diffstat (limited to 'django/contrib/postgres/aggregates/general.py')
-rw-r--r--django/contrib/postgres/aggregates/general.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/django/contrib/postgres/aggregates/general.py b/django/contrib/postgres/aggregates/general.py
index 5b3d22bf98..cd9a4bc349 100644
--- a/django/contrib/postgres/aggregates/general.py
+++ b/django/contrib/postgres/aggregates/general.py
@@ -1,4 +1,5 @@
from django.contrib.postgres.fields import JSONField
+from django.db.models import Value
from django.db.models.aggregates import Aggregate
__all__ = [
@@ -43,11 +44,12 @@ class JSONBAgg(Aggregate):
class StringAgg(Aggregate):
function = 'STRING_AGG'
- template = "%(function)s(%(distinct)s%(expressions)s, '%(delimiter)s')"
+ template = '%(function)s(%(distinct)s%(expressions)s)'
def __init__(self, expression, delimiter, distinct=False, **extra):
distinct = 'DISTINCT ' if distinct else ''
- super(StringAgg, self).__init__(expression, delimiter=delimiter, distinct=distinct, **extra)
+ delimiter_expr = Value(str(delimiter))
+ super(StringAgg, self).__init__(expression, delimiter_expr, distinct=distinct, **extra)
def convert_value(self, value, expression, connection, context):
if not value: