diff options
| author | Adrian Holovaty <adrian@holovaty.com> | 2008-04-28 21:15:05 +0000 |
|---|---|---|
| committer | Adrian Holovaty <adrian@holovaty.com> | 2008-04-28 21:15:05 +0000 |
| commit | 14d6ee2dc956d06fc1014e1b3c1f1410d553157d (patch) | |
| tree | 38e2c12086a0160a5374bec26e9d6baa5c4e0506 /tests/modeltests/basic | |
| parent | 13a6fd61c6b234cedf0ceebc7a66cce45c1006af (diff) | |
Changed Query.get_columns() to quote the 'AS' column names in an extra_select situation, to match pre-queryset-refactor behavior. Added unit tests that verify this and provide an example
git-svn-id: http://code.djangoproject.com/svn/django/trunk@7502 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests/modeltests/basic')
| -rw-r--r-- | tests/modeltests/basic/models.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/modeltests/basic/models.py b/tests/modeltests/basic/models.py index 51de8a50f8..d7c27cb15b 100644 --- a/tests/modeltests/basic/models.py +++ b/tests/modeltests/basic/models.py @@ -398,4 +398,16 @@ u'\u6797\u539f \u3081\u3050\u307f' >>> s = set([a10, a11, a12]) >>> Article.objects.get(headline='Article 11') in s True + +# The 'select' argument to extra() supports names with dashes in them, as long +# as you use values(). +>>> Article.objects.filter(pub_date__year=2008).extra(select={'dashed-value': '1'}).values('headline', 'dashed-value') +[{'headline': u'Article 11', 'dashed-value': 1}, {'headline': u'Article 12', 'dashed-value': 1}] + +# If you use 'select' with extra() and names containing dashes on a query +# that's *not* a values() query, those extra 'select' values will silently be +# ignored. +>>> articles = Article.objects.filter(pub_date__year=2008).extra(select={'dashed-value': '1', 'undashedvalue': '2'}) +>>> articles[0].undashedvalue +2 """ |
