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

queryset-refactor: Fixed a couple of typos that were messing up extra(select=...).

git-svn-id: http://code.djangoproject.com/svn/django/branches/queryset-refactor@6512 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Malcolm Tredinnick 2007-10-15 00:29:55 +00:00
parent 201c15dcb6
commit 05ebc901fe
3 changed files with 8 additions and 2 deletions

View File

@ -96,7 +96,7 @@ class _QuerySet(object):
else:
obj = self.model(*row[:index_end])
for i, k in enumerate(extra_select):
setattr(obj, k[0], row[index_end + i])
setattr(obj, k, row[index_end + i])
yield obj
def count(self):

View File

@ -342,7 +342,7 @@ class Query(object):
"""
qn = self.quote_name_unless_alias
result = []
if self.select or self.extra_select:
if self.select:
for col in self.select:
if isinstance(col, (list, tuple)):
result.append('%s.%s' % (qn(col[0]), qn(col[1])))

View File

@ -310,6 +310,12 @@ Bug #2076
>>> Ranking.objects.extra(tables=['django_site'], order_by=['-django_site.id', 'rank'])
[<Ranking: 1: a3>, <Ranking: 2: a2>, <Ranking: 3: a1>]
>>> qs = Ranking.objects.extra(select={'good': 'rank > 2'})
>>> [o.good for o in qs.extra(order_by=('-good',))] == [True, False, False]
True
>>> qs.extra(order_by=('-good', 'id'))
[<Ranking: 3: a1>, <Ranking: 2: a2>, <Ranking: 1: a3>]
Bugs #2874, #3002
>>> qs = Item.objects.select_related().order_by('note__note', 'name')
>>> list(qs)