summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorMalcolm Tredinnick <malcolm.tredinnick@gmail.com>2007-10-14 02:14:15 +0000
committerMalcolm Tredinnick <malcolm.tredinnick@gmail.com>2007-10-14 02:14:15 +0000
commit2c4013e74fcd5f7ba0865448d6ac39ba65463752 (patch)
tree2c2d318d1e3a13a5954c99eeeb332004cc7e57cd /django
parentb47231ee3e164855590b231d6092e54938d6ae53 (diff)
queryset-refactor: Fixed a problem in the isnull=True handling.
git-svn-id: http://code.djangoproject.com/svn/django/branches/queryset-refactor@6490 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django')
-rw-r--r--django/db/models/sql/query.py19
1 files changed, 10 insertions, 9 deletions
diff --git a/django/db/models/sql/query.py b/django/db/models/sql/query.py
index 7eb9d826bf..c9ae75a414 100644
--- a/django/db/models/sql/query.py
+++ b/django/db/models/sql/query.py
@@ -546,7 +546,7 @@ class Query(object):
opts = self.model._meta
alias = self.join((None, opts.db_table, None, None))
dupe_multis = (connection == AND)
- seen_aliases = []
+ join_list = []
done_split = not self.where
# FIXME: Using enumerate() here is expensive. We only need 'i' to
@@ -558,20 +558,21 @@ class Query(object):
if name == 'pk':
name = target_field.name
if joins is not None:
- seen_aliases.extend(joins)
+ join_list.append(joins)
last = joins
alias = joins[-1]
if connection == OR and not done_split:
if self.alias_map[joins[0]][ALIAS_REFCOUNT] == 1:
done_split = True
self.promote_alias(joins[0])
+ all_aliases = []
+ for a in join_list:
+ all_aliases.extend(a)
for t in self.tables[1:]:
- if t in seen_aliases:
+ if t in all_aliases:
continue
self.promote_alias(t)
break
- else:
- seen_aliases.extend(joins)
else:
# Normal field lookup must be the last field in the filter.
if i != len(parts) - 1:
@@ -580,13 +581,13 @@ class Query(object):
col = target_col or target_field.column
- if target_field is opts.pk and seen_aliases:
+ if target_field is opts.pk and join_list:
# An optimization: if the final join is against a primary key,
# we can go back one step in the join chain and compare against
# the lhs of the join instead. The result (potentially) involves
# one less table join.
self.unref_alias(alias)
- join = self.alias_map[seen_aliases[-1]][ALIAS_JOIN]
+ join = self.alias_map[join_list[-1][-1]][ALIAS_JOIN]
alias = join[LHS_ALIAS]
col = join[LHS_JOIN_COL]
@@ -595,12 +596,12 @@ class Query(object):
# join when connecting to the previous model. We make that
# adjustment here. We don't do this unless needed because it's less
# efficient at the database level.
- self.promote_alias(joins[0])
+ self.promote_alias(join_list[-1][0])
self.where.add([alias, col, orig_field, lookup_type, value],
connection)
if negate:
- if seen_aliases:
+ if join_list:
self.promote_alias(last[0])
self.where.negate()