Opened 9 years ago

Last modified 11 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
Pull Requests:4385 unmerged

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.

According to the ticket's flags, the next step(s) to move this issue forward are:

  • To improve the patch as described in the pull request review comments or on this ticket, then uncheck "Patch needs improvement".
  • If creating a new pull request, include a link to the pull request in the ticket comment when making that update. The usual format is: [https://github.com/django/django/pull/#### PR].

Change History (4)

comment:1 by Anssi Kääriäinen, 9 years ago

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 5 years ago by Simon Charette (previous) (diff)

comment:2 by Carsten Fuchs, 9 years ago

Cc: carsten.fuchs@… added

comment:3 by Tim Graham, 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 Ülgen Sarıkavak, 11 months ago

Cc: Ülgen Sarıkavak added
Note: See TracTickets for help on using tickets.
Back to Top