Skip to content

Commit

Permalink
queryset-refactor: For custom Q-like objects, pass in the used_aliases
Browse files Browse the repository at this point in the history
parameter (see [7462]) from Query.add_q() to their add_to_query() method. This
provides custom objects with the same context as Q's.


git-svn-id: http://code.djangoproject.com/svn/django/branches/queryset-refactor@7467 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information
malcolmt committed Apr 26, 2008
1 parent 67bfd15 commit dd432cc
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions django/db/models/sql/query.py
Expand Up @@ -1008,9 +1008,11 @@ def add_q(self, q_object, used_aliases=None):
Can also be used to add anything that has an 'add_to_query()' method.
"""
if used_aliases is None:
used_aliases = set()
if hasattr(q_object, 'add_to_query'):
# Complex custom objects are responsible for adding themselves.
q_object.add_to_query(self)
q_object.add_to_query(self, used_aliases)
return

if self.where and q_object.connector != AND and len(q_object) > 1:
Expand All @@ -1019,8 +1021,6 @@ def add_q(self, q_object, used_aliases=None):
else:
subtree = False
connector = AND
if used_aliases is None:
used_aliases = set()
for child in q_object.children:
if isinstance(child, Node):
self.where.start_subtree(connector)
Expand Down

0 comments on commit dd432cc

Please sign in to comment.