summaryrefslogtreecommitdiff
path: root/django/db/models/sql
diff options
context:
space:
mode:
authorMalcolm Tredinnick <malcolm.tredinnick@gmail.com>2007-10-15 00:29:27 +0000
committerMalcolm Tredinnick <malcolm.tredinnick@gmail.com>2007-10-15 00:29:27 +0000
commit201c15dcb62543ea66ff66858be088340ed50221 (patch)
tree3a128b0e7448b2d498a36efd95ef9bd71cb37ba9 /django/db/models/sql
parenta1d160e2ea22cb010b276cfc2a085f9cd3d81b22 (diff)
queryset-refactor: Added an order_by parameter to extra(). Refs #2076.
git-svn-id: http://code.djangoproject.com/svn/django/branches/queryset-refactor@6511 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/db/models/sql')
-rw-r--r--django/db/models/sql/query.py15
1 files changed, 10 insertions, 5 deletions
diff --git a/django/db/models/sql/query.py b/django/db/models/sql/query.py
index 35c6cc28dc..5d96ec8020 100644
--- a/django/db/models/sql/query.py
+++ b/django/db/models/sql/query.py
@@ -378,9 +378,14 @@ class Query(object):
for alias in self.tables:
if not self.alias_map[alias][ALIAS_REFCOUNT]:
continue
- name, alias, join_type, lhs, lhs_col, col = \
- self.alias_map[alias][ALIAS_JOIN]
- alias_str = (alias != name and ' AS %s' % alias or '')
+ join = self.alias_map[alias][ALIAS_JOIN]
+ if join:
+ name, alias, join_type, lhs, lhs_col, col = join
+ alias_str = (alias != name and ' AS %s' % alias or '')
+ else:
+ join_type = None
+ alias_str = ''
+ name = alias
if join_type:
result.append('%s %s%s ON (%s.%s = %s.%s)'
% (join_type, qn(name), alias_str, qn(lhs),
@@ -464,8 +469,8 @@ class Query(object):
def find_ordering_name(self, name, opts, alias=None, default_order='ASC'):
"""
- Returns the table alias (the name might not be unambiguous, the alias
- will be) and column name for ordering by the given 'name' parameter.
+ Returns the table alias (the name might be ambiguous, the alias will
+ not be) and column name for ordering by the given 'name' parameter.
The 'name' is of the form 'field1__field2__...__fieldN'.
"""
name, order = get_order_dir(name, default_order)