From c127f0117d75220e346625cd8a009fb6a317ece1 Mon Sep 17 00:00:00 2001 From: Malcolm Tredinnick Date: Sat, 16 Aug 2008 20:40:00 +0000 Subject: [PATCH] Fixed #8283 -- Fixed an edge case when adding things to the "where" tree and combining different connector types. git-svn-id: http://code.djangoproject.com/svn/django/trunk@8413 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/utils/tree.py | 2 +- tests/regressiontests/queries/models.py | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/django/utils/tree.py b/django/utils/tree.py index 5dd9f56799..a9028b834b 100644 --- a/django/utils/tree.py +++ b/django/utils/tree.py @@ -87,7 +87,7 @@ 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: + if node in self.children and conn_type == self.connector: return if len(self.children) < 2: self.connector = conn_type diff --git a/tests/regressiontests/queries/models.py b/tests/regressiontests/queries/models.py index 894554d30e..60a3cfe2ca 100644 --- a/tests/regressiontests/queries/models.py +++ b/tests/regressiontests/queries/models.py @@ -891,6 +891,12 @@ True >>> Celebrity.objects.count() == num_celebs True +Bug #8283 -- Checking that applying filters after a disjunction works correctly. +>>> (ExtraInfo.objects.filter(note=n1)|ExtraInfo.objects.filter(info='e2')).filter(note=n1) +[] +>>> (ExtraInfo.objects.filter(info='e2')|ExtraInfo.objects.filter(note=n1)).filter(note=n1) +[] + """} # In Python 2.3, exceptions raised in __len__ are swallowed (Python issue