mirror of
https://github.com/django/django.git
synced 2025-07-06 10:49:17 +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:
parent
201c15dcb6
commit
05ebc901fe
@ -96,7 +96,7 @@ class _QuerySet(object):
|
|||||||
else:
|
else:
|
||||||
obj = self.model(*row[:index_end])
|
obj = self.model(*row[:index_end])
|
||||||
for i, k in enumerate(extra_select):
|
for i, k in enumerate(extra_select):
|
||||||
setattr(obj, k[0], row[index_end + i])
|
setattr(obj, k, row[index_end + i])
|
||||||
yield obj
|
yield obj
|
||||||
|
|
||||||
def count(self):
|
def count(self):
|
||||||
|
@ -342,7 +342,7 @@ class Query(object):
|
|||||||
"""
|
"""
|
||||||
qn = self.quote_name_unless_alias
|
qn = self.quote_name_unless_alias
|
||||||
result = []
|
result = []
|
||||||
if self.select or self.extra_select:
|
if self.select:
|
||||||
for col in self.select:
|
for col in self.select:
|
||||||
if isinstance(col, (list, tuple)):
|
if isinstance(col, (list, tuple)):
|
||||||
result.append('%s.%s' % (qn(col[0]), qn(col[1])))
|
result.append('%s.%s' % (qn(col[0]), qn(col[1])))
|
||||||
|
@ -310,6 +310,12 @@ Bug #2076
|
|||||||
>>> Ranking.objects.extra(tables=['django_site'], order_by=['-django_site.id', 'rank'])
|
>>> Ranking.objects.extra(tables=['django_site'], order_by=['-django_site.id', 'rank'])
|
||||||
[<Ranking: 1: a3>, <Ranking: 2: a2>, <Ranking: 3: a1>]
|
[<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
|
Bugs #2874, #3002
|
||||||
>>> qs = Item.objects.select_related().order_by('note__note', 'name')
|
>>> qs = Item.objects.select_related().order_by('note__note', 'name')
|
||||||
>>> list(qs)
|
>>> list(qs)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user