Code

Opened 6 years ago

Closed 6 years ago

#7526 closed (duplicate)

Query Set Refactor handling of INNER JOINs

Reported by: khoobks Owned by: gav
Component: Database layer (models, ORM) Version: master
Severity: Keywords: query set refactor order_by inner join
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

Hi,

The best way for me to explain the issue I have discovered is to run the test case provided with this ticket. The test case is a modification of the many_to_one test case that comes with Django. I have commented out the "unnecessary" bits for clarity.

The problem that I am reporting is that due to the way that the ordering is expressed in the example, a join to the related table is necessary.
When performing any query on this model (except a count) an INNER JOIN is used in the SQL command. If we are trying to get all rows (from a table that contains some rows) using "all()", an INNER JOIN will be performed to the related table which, in the example contains no rows. This results in the "all()" function returning an empty query set which is incorrect. I think.

Regards

Attachments (1)

models.py (1.7 KB) - added by khoobks 6 years ago.
Test case illustrating the issue.

Download all attachments as: .zip

Change History (4)

Changed 6 years ago by khoobks

Test case illustrating the issue.

comment:1 Changed 6 years ago by gav

  • Component changed from Core framework to Database wrapper
  • Needs documentation unset
  • Needs tests unset
  • Owner changed from nobody to gav
  • Patch needs improvement unset
  • Status changed from new to assigned

Can you please check the patch filed against #7512? I tried it out, and it appears to resolve this issue as well. If so, let's close this ticket as a dupe, and if you have anything further that this ticket doesn't yet cover, you can add it to the comment thread on that ticket.

comment:2 Changed 6 years ago by khoobks

I agree. I think mine is a dupe.
I has a look at #7512 and that seemed to sort out the issue.

Thanks

comment:3 Changed 6 years ago by gav

  • Resolution set to duplicate
  • Status changed from assigned to closed

Dupe of #7512.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.