mirror of
https://github.com/django/django.git
synced 2025-08-08 04:48:27 +00:00
Fixed #24766 -- Added join promotion for Case expressions
This commit is contained in:
parent
8e86d9d3df
commit
be9d645346
3 changed files with 42 additions and 1 deletions
|
@ -87,7 +87,12 @@ class Q(tree.Node):
|
|||
return clone
|
||||
|
||||
def resolve_expression(self, query=None, allow_joins=True, reuse=None, summarize=False, for_save=False):
|
||||
clause, _ = query._add_q(self, reuse, allow_joins=allow_joins)
|
||||
# We must promote any new joins to left outer joins so that when Q is
|
||||
# used as an expression, rows aren't filtered due to joins.
|
||||
joins_before = query.tables[:]
|
||||
clause, joins = query._add_q(self, reuse, allow_joins=allow_joins)
|
||||
joins_to_promote = [j for j in joins if j not in joins_before]
|
||||
query.promote_joins(joins_to_promote)
|
||||
return clause
|
||||
|
||||
@classmethod
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue