Opened 11 years ago

Closed 11 years ago

#21376 closed Bug (fixed)

Regression 2 in query join promotion logic

Reported by: Tim Graham Owned by: Anssi Kääriäinen
Component: Database layer (models, ORM) Version: dev
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

(master only) I think there's a regression in the following commit - test case that passes before the commit attached. I imagine we may want to introduce a new model rather than modify ObjectC as done in the patch.

https://github.com/django/django/commit/ecaba3602837d1e02fe1e961f7d3bf9086453259

(regression 1 was #21366)

Attachments (1)

21376_test.diff (1.4 KB ) - added by Tim Graham 11 years ago.

Download all attachments as: .zip

Change History (6)

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

Is this really a regression? For the query to produce any results objectb must be 1, and if objectb is 1, then LEFT JOIN will not produce any more results. This of course assumes that foreign key constraints are in effect, but that assumption has always been there for the ORM.

Rewriting the test to show that wrong results are produced would make it clear what the regression is. Not producing a left join in a case where it was done earlier isn't a regression.

comment:2 by Tim Graham, 11 years ago

Owner: changed from Anssi Kääriäinen to Tim Graham
Status: newassigned

I'll rewrite the test.

by Tim Graham, 11 years ago

Attachment: 21376_test.diff added

comment:3 by Tim Graham, 11 years ago

Owner: Tim Graham removed
Status: assignednew

Test should now be sufficient, I think.

comment:4 by Anssi Kääriäinen, 11 years ago

Owner: set to Anssi Kääriäinen
Status: newassigned
Triage Stage: UnreviewedAccepted

comment:5 by Anssi Kääriäinen <akaariai@…>, 11 years ago

Resolution: fixed
Status: assignedclosed

In 6fe2b001dba45134d7c10729c57959995e241a88:

Fixed #21376 -- New implementation for query join promotion logic

This commit introduced a new class JoinPromoter that can be used to
abstract away join promotion problems for complex filter conditions.
Query._add_q() and Query.combine() now use the new class.

Also, added a lot of comments about why join promotion is done the way
it is.

Thanks to Tim Graham for original report and testing the changes, and
for Loic Bistuer for review.

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