diff options
| author | Russell Keith-Magee <russell@keith-magee.com> | 2009-02-23 14:47:59 +0000 |
|---|---|---|
| committer | Russell Keith-Magee <russell@keith-magee.com> | 2009-02-23 14:47:59 +0000 |
| commit | 542709d0d1796326dd1edacf32fc1198cfad2869 (patch) | |
| tree | 40578c8972862606d7ddb0dad9c7e0e163b160e0 /django/db/models/sql/where.py | |
| parent | 4bd24474c02a6f3c70e8111ac262fabf2fc5f454 (diff) | |
Fixed #10182 -- Corrected realiasing and the process of evaluating values() for queries with aggregate clauses. This means that aggregate queries can now be used as subqueries (such as in an __in clause). Thanks to omat for the report.
This involves a slight change to the interaction of annotate() and values() clauses that specify a list of columns. See the docs for details.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@9888 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/db/models/sql/where.py')
| -rw-r--r-- | django/db/models/sql/where.py | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/django/db/models/sql/where.py b/django/db/models/sql/where.py index 1d4df127fe..43ac42489a 100644 --- a/django/db/models/sql/where.py +++ b/django/db/models/sql/where.py @@ -213,10 +213,14 @@ class WhereNode(tree.Node): elif isinstance(child, tree.Node): self.relabel_aliases(change_map, child) else: - elt = list(child[0]) - if elt[0] in change_map: - elt[0] = change_map[elt[0]] - node.children[pos] = (tuple(elt),) + child[1:] + if isinstance(child[0], (list, tuple)): + elt = list(child[0]) + if elt[0] in change_map: + elt[0] = change_map[elt[0]] + node.children[pos] = (tuple(elt),) + child[1:] + else: + child[0].relabel_aliases(change_map) + # Check if the query value also requires relabelling if hasattr(child[3], 'relabel_aliases'): child[3].relabel_aliases(change_map) |
