Skip to content

Commit

Permalink
Fixed #21376 -- New implementation for query join promotion logic
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
akaariai committed Nov 7, 2013
1 parent ae029b4 commit 6fe2b00
Show file tree
Hide file tree
Showing 4 changed files with 161 additions and 137 deletions.
1 change: 1 addition & 0 deletions django/db/models/sql/expressions.py
Expand Up @@ -60,6 +60,7 @@ def prepare_leaf(self, node, query, allow_joins):
field, sources, opts, join_list, path = query.setup_joins(
field_list, query.get_meta(),
query.get_initial_alias(), self.reuse)
self._used_joins = join_list
targets, _, join_list = query.trim_joins(sources, join_list, path)
if self.reuse is not None:
self.reuse.update(join_list)
Expand Down

0 comments on commit 6fe2b00

Please sign in to comment.