Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#24924 closed Uncategorized (fixed)

Incorrect Join Promotion with Annotations

Reported by: Mark Lavin Owned by: nobody
Component: Uncategorized Version: 1.8
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

This was originally addressed in #24766 and released in 1.8.2 but as noted here https://code.djangoproject.com/ticket/24766#comment:7 this problem still exists if there are multiple annotations. Working on a failing test case.

Attachments (1)

24924.diff (2.2 KB) - added by Rob Lineberger 5 years ago.
Failing test case

Download all attachments as: .zip

Change History (5)

Changed 5 years ago by Rob Lineberger

Attachment: 24924.diff added

Failing test case

comment:1 Changed 5 years ago by Rob Lineberger

Attached a test case that fails because of this issue.

$ python runtests.py expressions_case
Creating test database for alias 'default'...
Creating test database for alias 'other'...
......................................F.....................s...............
======================================================================
FAIL: test_join_promotion_with_multiple_annotations (expressions_case.tests.CaseExpressionTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/rob/rob/caktus/django/tests/expressions_case/tests.py", line 1073, in test_join_promotion_with_multiple_annotations
    lambda x: (x, x.foo, x.bar)
  File "/home/rob/rob/caktus/django/django/test/testcases.py", line 932, in assertQuerysetEqual
    return self.assertEqual(list(items), values, msg=msg)
AssertionError: Lists differ: [] != [(<CaseTestModel: 1, 1>, 3, 5)]

Second list contains 1 additional elements.
First extra element 0:
(<CaseTestModel: 1, 1>, 3, 5)

- []
+ [(<CaseTestModel: 1, 1>, 3, 5)]

----------------------------------------------------------------------
Ran 76 tests in 0.172s

FAILED (failures=1, skipped=1)
Destroying test database for alias 'default'...
Destroying test database for alias 'other'...

The query returns an empty list because of the inner join.

comment:2 Changed 5 years ago by Mark Lavin

Has patch: set

Added PR to fix https://github.com/django/django/pull/4810. Docs added under the assumption that this bug would be backported to 1.8.X.

comment:3 Changed 5 years ago by Tim Graham <timograham@…>

Resolution: fixed
Status: newclosed

In 541f4ea5:

Fixed #24924 -- Join promotion for multiple Case expressions

comment:4 Changed 5 years ago by Tim Graham <timograham@…>

In 0cfb7ed:

[1.8.x] Fixed #24924 -- Join promotion for multiple Case expressions

Backport of 541f4ea546ad3065852db816769ba6b584e3f373 from master

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