Opened 12 years ago
Closed 12 years ago
#19500 closed Bug (fixed)
Join reuse regression
Reported by: | Anssi Kääriäinen | Owned by: | nobody |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | dev |
Severity: | Normal | Keywords: | |
Cc: | charette.s@… | Triage Stage: | Accepted |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | yes |
Easy pickings: | no | UI/UX: | no |
Description
The commit 68847135bc9acb2c51c2d36797d0a85395f0cd35 for ticket #18748 caused a severe regression in join reuse. Chained filters for direct foreign keys do not reuse existing joins at all. For example
qs.filter(fk__somecol__gt=1).filter(fk__somecol__lt=10)
causes two joins instead of one.
The patch at https://github.com/akaariai/django/commit/688ec5aca2ca387774016aef78560c199d480b6c fixes the issue and adds various test for join reuse. It actually simplifies the code a little.
As a bonus we can now correctly reuse joins in chained filter() calls when using reverse o2o fields.
I think I will commit the patch soon as currently the code isn't behaving nicely.
Change History (3)
comment:1 by , 12 years ago
Cc: | added |
---|---|
Patch needs improvement: | set |
comment:2 by , 12 years ago
The mentioned issues are fixed in https://github.com/akaariai/django/commit/85b413918324b6bd10170274d440fe403de0e105
comment:3 by , 12 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Added some comments on the patch over github.