Django

Code

Changeset 6957

Show
Ignore:
Timestamp:
12/19/07 04:57:54 (7 months ago)
Author:
mtredinnick
Message:

queryset-refactor: Fixed a problem when adding certain additional filters to a queryset that has precisely one filter attached already.

Refs #6154.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/branches/queryset-refactor/django/db/models/sql/query.py

    r6899 r6957  
    793793            return 
    794794 
     795        if self.where and q_object.connector != AND and len(q_object) > 1: 
     796            self.where.start_subtree(AND) 
     797            subtree = True 
     798        else: 
     799            subtree = False 
    795800        for child in q_object.children: 
    796801            if isinstance(child, Node): 
     
    800805            else: 
    801806                self.add_filter(child, q_object.connector, q_object.negated) 
     807        if subtree: 
     808            self.where.end_subtree() 
    802809 
    803810    def setup_joins(self, names, opts, alias, dupe_multis): 
  • django/branches/queryset-refactor/django/utils/tree.py

    r6866 r6957  
    8888        """ 
    8989        Sets up internal state so that new nodes are added to a subtree of the 
    90         current node. The conn_type is required so that the new subtree is 
    91         connected correctly to any existing nodes in the tree
     90        current node. The conn_type specifies how the sub-tree is joined to the 
     91        existing children
    9292        """ 
    9393        if len(self.children) == 1: 
  • django/branches/queryset-refactor/tests/regressiontests/queries/models.py

    r6901 r6957  
    460460[<Item: four>] 
    461461 
     462Bug #6154 
     463Multiple filter statements are joined using "AND" all the time. 
     464 
     465>>> Author.objects.filter(id=a1.id).filter(Q(extra__note=n1)|Q(item__note=n3)) 
     466[<Author: a1>] 
     467>>> Author.objects.filter(Q(extra__note=n1)|Q(item__note=n3)).filter(id=a1.id) 
     468[<Author: a1>] 
    462469"""} 
    463470