diff options
| author | Malcolm Tredinnick <malcolm.tredinnick@gmail.com> | 2008-03-20 19:16:04 +0000 |
|---|---|---|
| committer | Malcolm Tredinnick <malcolm.tredinnick@gmail.com> | 2008-03-20 19:16:04 +0000 |
| commit | 04da22633fcda983cb9ee69e63b2ebe99301b717 (patch) | |
| tree | 1542ad9bcbfa92d45cd27e0ab48c4b73287a5180 /tests/regressiontests/queries/models.py | |
| parent | e2dfad15f14f4da61ec7bcfc5cab2b083fd7ec63 (diff) | |
queryset-refactor: Fixed up extra(select=...) calls with parameters so that the
parameters are substituted in correctly in all cases. This introduces an extra
argument to extra() for this purpose; no alternative there.
Also fixed values() to work if you don't specify *all* the extra select aliases
in the values() call.
Refs #3141.
git-svn-id: http://code.djangoproject.com/svn/django/branches/queryset-refactor@7340 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests/regressiontests/queries/models.py')
| -rw-r--r-- | tests/regressiontests/queries/models.py | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/tests/regressiontests/queries/models.py b/tests/regressiontests/queries/models.py index 2db5bf8a34..9b86d60fde 100644 --- a/tests/regressiontests/queries/models.py +++ b/tests/regressiontests/queries/models.py @@ -282,6 +282,10 @@ Bug #1878, #2939 >>> xx.save() >>> Item.objects.exclude(name='two').values('creator', 'name').distinct().count() 4 +>>> Item.objects.exclude(name='two').extra(select={'foo': '%s'}, select_params=(1,)).values('creator', 'name', 'foo').distinct().count() +4 +>>> Item.objects.exclude(name='two').extra(select={'foo': '%s'}, select_params=(1,)).values('creator', 'name').distinct().count() +4 >>> xx.delete() Bug #2253 @@ -386,6 +390,8 @@ AssertionError: Cannot combine queries on two different base models. Bug #3141 >>> Author.objects.extra(select={'foo': '1'}).count() 4 +>>> Author.objects.extra(select={'foo': '%s'}, select_params=(1,)).count() +4 Bug #2400 >>> Author.objects.filter(item__isnull=True) @@ -462,6 +468,11 @@ True >>> qs.extra(order_by=('-good', 'id')) [<Ranking: 3: a1>, <Ranking: 2: a2>, <Ranking: 1: a3>] +# Despite having some extra aliases in the query, we can still omit them in a +# values() query. +>>> qs.values('id', 'rank').order_by('id') +[{'id': 1, 'rank': 2}, {'id': 2, 'rank': 1}, {'id': 3, 'rank': 3}] + Bugs #2874, #3002 >>> qs = Item.objects.select_related().order_by('note__note', 'name') >>> list(qs) @@ -533,7 +544,7 @@ thus fail.) # This slightly odd comparison works aorund the fact that PostgreSQL will # return 'one' and 'two' as strings, not Unicode objects. It's a side-effect of # using constants here and not a real concern. ->>> d = Item.objects.extra(select=SortedDict(s), params=params).values('a', 'b')[0] +>>> d = Item.objects.extra(select=SortedDict(s), select_params=params).values('a', 'b')[0] >>> d == {'a': u'one', 'b': u'two'} True |
