expressions.py 405 B

1234567891011121314
  1. from django.contrib.postgres.fields import ArrayField
  2. from django.db.models import Subquery
  3. from django.utils.functional import cached_property
  4. class ArraySubquery(Subquery):
  5. template = "ARRAY(%(subquery)s)"
  6. def __init__(self, queryset, **kwargs):
  7. super().__init__(queryset, **kwargs)
  8. @cached_property
  9. def output_field(self):
  10. return ArrayField(self.query.output_field)