1
0
mirror of https://github.com/django/django.git synced 2025-07-06 18:59:13 +00:00

queryset-refactor: Fixed handling of extra(tables=...). In passing, this solves

a duplicate table / bad SQL problem. Refs #2496.


git-svn-id: http://code.djangoproject.com/svn/django/branches/queryset-refactor@6504 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Malcolm Tredinnick 2007-10-14 03:46:44 +00:00
parent 93b4199912
commit 6678de130c
2 changed files with 9 additions and 1 deletions

View File

@ -371,7 +371,11 @@ class Query(object):
qn(lhs_col), qn(alias), qn(col)))
else:
result.append('%s%s' % (qn(name), alias_str))
result.extend(self.extra_tables)
extra_tables = []
for t in self.extra_tables:
alias, created = self.table_alias(t)
if created:
result.append(', %s' % alias)
return result, []
def get_grouping(self):

View File

@ -202,5 +202,9 @@ Bug #2400
[<Author: a3>]
>>> Tag.objects.filter(item__isnull=True)
[<Tag: t5>]
Bug #2496
>>> Item.objects.extra(tables=['queries_author']).select_related().order_by('name')[:1]
[<Item: four>]
"""}