Opened 5 years ago

Last modified 9 months ago

#25991 new Bug

A new implementation for exclude() queries

Reported by: Anssi Kääriäinen Owned by: nobody
Component: Database layer (models, ORM) Version: master
Severity: Normal Keywords:
Cc: carsten.fuchs@… Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: yes
Easy pickings: no UI/UX: no


The idea is to prewalk the Q-object, split it into parts that need to go into a subquery, and then add the filtered subqueries into the main query.

This ticket deals with problems of doing Author.objects.exclude(friends__age__gte=20, friends__age__lte=40). Currently this creates two joins to friends, so that any author with either a friend older than 20 or a friend younger than 40 is matched. The correct interpretation is that any author with a friend with age between 20 and 40 is matched.

Change History (3)

comment:1 Changed 5 years ago by Anssi Kääriäinen

Related tickets:

The first one (#14645) deals with the issue mentioned in this ticket's description. It should be fixed by this ticket. The rest of the tickets are various failures in .exclude() queries, and these might be fixed by this ticket, but I haven't verified those yet.

Last edited 9 months ago by Simon Charette (previous) (diff)

comment:2 Changed 5 years ago by Carsten Fuchs

Cc: carsten.fuchs@… added

comment:3 Changed 5 years ago by Tim Graham

Patch needs improvement: set

As Ansii noted on the pull request, "I still found some cases that do not work the way they should. So, this needs a bit more work...".

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