#35235: ArrayAgg() doesn't return default when filter contains __in=[].
----------------------------------+--------------------------------------
Reporter: Per Carlsen | Owner: Sharon Woo
Type: Bug | Status: assigned
Component: contrib.postgres | Version: 5.0
Severity: Normal | Resolution:
Keywords: ArrayAgg | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
----------------------------------+--------------------------------------
Comment (by David Sanders):
Looks like this patch fixes the issue:
{{{
--- a/django/db/models/aggregates.py
+++ b/django/db/models/aggregates.py
@@ -92,7 +92,7 @@ class Aggregate(Func):
return c
if hasattr(default, "resolve_expression"):
default = default.resolve_expression(query, allow_joins,
reuse, summarize)
- if default._output_field_or_none is None:
+ if default._resolve_output_field() is None:
default.output_field = c._output_field_or_none
else:
default = Value(default, c._output_field_or_none)
}}}
The problem is `Aggregate.resolve_expression()` calls
`default._output_field_or_none` which then caches the `None` because it's
a `@cached_property`.... which makes setting the `output_field`
essentially a no-op.
--
Ticket URL: <https://code.djangoproject.com/ticket/35235#comment:5>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/0107018dc63f336f-3b7cde50-3a66-4462-8d43-0fa563e06aa7-000000%40eu-central-1.amazonses.com.