diff options
| author | Malcolm Tredinnick <malcolm.tredinnick@gmail.com> | 2007-10-24 04:22:23 +0000 |
|---|---|---|
| committer | Malcolm Tredinnick <malcolm.tredinnick@gmail.com> | 2007-10-24 04:22:23 +0000 |
| commit | f951d97d9937370a602753f0d530e5b2bbdac69d (patch) | |
| tree | f277fb3b135a5964c52b058f41e9317345afe717 /tests | |
| parent | abcb70e5245095628c4a00816138af9382e306fd (diff) | |
queryset-refactor: Added the ability to apply parameters to the select
fragments in QuerySet.extra(). Refs #2902
git-svn-id: http://code.djangoproject.com/svn/django/branches/queryset-refactor@6603 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/regressiontests/queries/models.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/regressiontests/queries/models.py b/tests/regressiontests/queries/models.py index 0a7ae286b7..f0514dcee9 100644 --- a/tests/regressiontests/queries/models.py +++ b/tests/regressiontests/queries/models.py @@ -379,5 +379,20 @@ The all() method on querysets returns a copy of the queryset. >>> q1 = Item.objects.order_by('name') >>> id(q1) == id(q1.all()) False + +Bug #2902 +Parameters can be given to extra_select, *if* you use a SortedDict. + +(First we need to know which order the keys fall in "naturally" on your system, +so we can put things in the wrong way around from normal. A normal dict would +thus fail.) +>>> from django.utils.datastructures import SortedDict +>>> s = [('a', '%s'), ('b', '%s')] +>>> params = ['one', 'two'] +>>> if {'a': 1, 'b': 2}.keys() == ['a', 'b']: +... s.reverse() +... params.reverse() +>>> Item.objects.extra(select=SortedDict(s), params=params).values('a','b')[0] +{'a': u'one', 'b': u'two'} """} |
