summaryrefslogtreecommitdiff
path: root/django/utils/tree.py
diff options
context:
space:
mode:
authorAnssi Kääriäinen <akaariai@gmail.com>2012-09-30 17:51:06 +0300
committerAnssi Kääriäinen <akaariai@gmail.com>2012-09-30 17:51:06 +0300
commit28abf5f0ebc9d380f25dd278d7ef4642c4504545 (patch)
tree6ec2caaaec8576660780adeb22d6dd09f5ef84d4 /django/utils/tree.py
parentddd7d1af203d6d260c970d8ee8749fedbce6bba1 (diff)
Fixed #16211 -- Added comparison and negation ops to F() expressions
Work done by Walter Doekes and Trac alias knoeb. Reviewed by Simon Charette.
Diffstat (limited to 'django/utils/tree.py')
-rw-r--r--django/utils/tree.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/django/utils/tree.py b/django/utils/tree.py
index 717181d2b9..6229493544 100644
--- a/django/utils/tree.py
+++ b/django/utils/tree.py
@@ -88,8 +88,12 @@ class Node(object):
Otherwise, the whole tree is pushed down one level and a new root
connector is created, connecting the existing tree and the new node.
"""
- if node in self.children and conn_type == self.connector:
- return
+ # Using for loop with 'is' instead of 'if node in children' so node
+ # __eq__ method doesn't get called. The __eq__ method can be overriden
+ # by subtypes, for example the F-expression.
+ for child in self.children:
+ if node is child and conn_type == self.connector:
+ return
if len(self.children) < 2:
self.connector = conn_type
if self.connector == conn_type: