Opened 22 months ago

Last modified 22 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

Description

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 22 months 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.

comment:2 Changed 22 months ago by Carsten Fuchs

Cc: carsten.fuchs@… added

comment:3 Changed 22 months 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