summaryrefslogtreecommitdiff
path: root/django/contrib/postgres/aggregates/general.py
diff options
context:
space:
mode:
authorSergey Fedoseev <fedoseev.sergey@gmail.com>2017-12-31 00:46:52 +0500
committerTim Graham <timograham@gmail.com>2017-12-30 14:46:52 -0500
commit149061103829fb3ad74d050b4ae3cc815b2f451c (patch)
treefa618659ea070a57c0e46984af3849e851b3c746 /django/contrib/postgres/aggregates/general.py
parent58ec55b157b3c4cc9dc0a944804f8a719ff4e12f (diff)
downloaddjango-149061103829fb3ad74d050b4ae3cc815b2f451c.tar.gz
Fixed #28908 -- Allowed ArrayField lookups on ArrayAgg annotations.
Diffstat (limited to 'django/contrib/postgres/aggregates/general.py')
-rw-r--r--django/contrib/postgres/aggregates/general.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/django/contrib/postgres/aggregates/general.py b/django/contrib/postgres/aggregates/general.py
index 471eda2970..806ecd1b78 100644
--- a/django/contrib/postgres/aggregates/general.py
+++ b/django/contrib/postgres/aggregates/general.py
@@ -1,4 +1,4 @@
-from django.contrib.postgres.fields import JSONField
+from django.contrib.postgres.fields import ArrayField, JSONField
from django.db.models.aggregates import Aggregate
__all__ = [
@@ -10,6 +10,10 @@ class ArrayAgg(Aggregate):
function = 'ARRAY_AGG'
template = '%(function)s(%(distinct)s%(expressions)s)'
+ @property
+ def output_field(self):
+ return ArrayField(self.source_expressions[0].output_field)
+
def __init__(self, expression, distinct=False, **extra):
super().__init__(expression, distinct='DISTINCT ' if distinct else '', **extra)