Opened 9 years ago
Last modified 8 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: | dev |
Severity: | Normal | Keywords: | |
Cc: | carsten.fuchs@…, Ülgen Sarıkavak | 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 (4)
comment:2 by , 9 years ago
Cc: | added |
---|
comment:3 by , 9 years ago
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...".
comment:4 by , 8 months ago
Cc: | added |
---|
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.