Opened 4 weeks ago

Closed 3 weeks ago

Last modified 3 weeks ago

#36631 closed Bug (worksforme)

Support nested relations in FilteredRelation's condition is broken

Reported by: nad2000 Owned by:
Component: Database layer (models, ORM) Version: 5.2
Severity: Normal Keywords: FilteredRelation nested relations
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

The support of nested relations in FilteredRelation, implemented with #29789 Support nested relations in FilteredRelation's condition (3.2), is broken:

This bug resurfaced with 5.2. (after upgrading from 5.1.9). The queryset causing this issue ("ValueError: FilteredRelation's condition doesn't support nested relations deeper than the relation_name (got 'conflict_of_interestspanellistuser' for 'conflict_of_interests')."):

queryset = queryset.filter(round__panellists__user=user, state="submitted").annotate(
    coi=FilteredRelation(
        "conflict_of_interests",
        condition=Q(conflict_of_interests__panellist__user=user),
    )
)

Change History (3)

comment:1 by Jacob Walls, 3 weeks ago

Resolution: duplicate
Status: newclosed

comment:2 by Jacob Walls, 3 weeks ago

If you provide your models, we can verify that the error is working as intended. As described in ticket:29789#comment:31, it looks like Django 5.1.9 failed to raise an error in this case (you could verify by adding __exact to the lookup).

comment:3 by Jacob Walls, 3 weeks ago

Resolution: duplicateworksforme
Note: See TracTickets for help on using tickets.
Back to Top