summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMalcolm Tredinnick <malcolm.tredinnick@gmail.com>2008-03-18 13:53:22 +0000
committerMalcolm Tredinnick <malcolm.tredinnick@gmail.com>2008-03-18 13:53:22 +0000
commit150b7ac7702195aa2d322566197be43829a6d64d (patch)
treee48d6092a7ad2991fcb9bbea7c0f166ed632a865
parentbec21f0e2b5ab44565066cdab25ec6746d96efcc (diff)
queryset-refactor: Allow exclusions when bumping the aliases on a subquery.
git-svn-id: http://code.djangoproject.com/svn/django/branches/queryset-refactor@7288 bcc190cf-cafb-0310-a4f2-bffc1f526a37
-rw-r--r--django/db/models/sql/query.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/django/db/models/sql/query.py b/django/db/models/sql/query.py
index 296eb285e1..62a5670af8 100644
--- a/django/db/models/sql/query.py
+++ b/django/db/models/sql/query.py
@@ -652,7 +652,7 @@ class Query(object):
data[LHS_ALIAS] = change_map[lhs]
self.alias_map[alias] = tuple(data)
- def bump_prefix(self):
+ def bump_prefix(self, exceptions=()):
"""
Changes the alias prefix to the next letter in the alphabet and
relabels all the aliases. Even tables that previously had no alias will
@@ -661,12 +661,17 @@ class Query(object):
Subclasses who create their own prefix should override this method to
produce a similar result (a new prefix and relabelled aliases).
+
+ The 'exceptions' parameter is a container that holds alias names which
+ should not be changed.
"""
assert ord(self.alias_prefix) < ord('Z')
self.alias_prefix = chr(ord(self.alias_prefix) + 1)
change_map = {}
prefix = self.alias_prefix
for pos, alias in enumerate(self.tables):
+ if alias in exceptions:
+ continue
new_alias = '%s%d' % (prefix, pos)
change_map[alias] = new_alias
self.tables[pos] = new_alias