#31660 closed Bug (fixed)
AttributeError is raised while grouping on reverse relation.
Reported by: | Tomasz Szymański | Owned by: | Mariusz Felisiak |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | 3.0 |
Severity: | Release blocker | Keywords: | |
Cc: | Mikail | Triage Stage: | Accepted |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Aggregation by using StringAgg works in 3.0.6, doesn't in 3.0.7
qs = qs.annotate( filtered_attribute=models.FilteredRelation( relation_name="attributes", ), concatenated_values=models.Case( models.When( models.Q(filtered_attribute=None), then=models.Value(""), ), default=StringAgg( models.F("name"), delimiter=",", ), output_field=models.CharField(), ), )
the exception raised in 3.0.7:
'ManyToOneRel' object has no attribute 'select_format'
Possibly broken by:
https://github.com/django/django/pull/12913
Attatching a zipped project, steps to reproduce:
docker-compose build
docker-compose docker-compose run web python manage.py migrate
docker-compose up
- Either access
localhost:8000/bug
or run the tests:docker-compose run web python manage.py test
Attachments (1)
Change History (9)
by , 5 years ago
Attachment: | django-bug.zip added |
---|
comment:1 by , 5 years ago
Owner: | changed from | to
---|---|
Severity: | Normal → Release blocker |
Status: | new → assigned |
Summary: | AttributeError is raised while using StringAgg aggregating function on PostgreSQL databases. → AttributeError is raised while grouping on reverse relation. |
Triage Stage: | Unreviewed → Accepted |
Thanks for the report.
Regression in 3a941230c85b2702a5e1cd97e17251ce21057efa.
comment:2 by , 5 years ago
The fact a ManyToOneRel
rel makes it's way there is problematic, that means an expression has output_field: ManyToOneRel
.
comment:3 by , 5 years ago
Cc: | added |
---|
Note:
See TracTickets
for help on using tickets.
Sample project with the bug-triggering code and testcase implemented