Django

Code

Show
Ignore:
Timestamp:
04/28/08 16:15:05 (6 months ago)
Author:
adrian
Message:

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

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/tests/modeltests/basic/models.py

    r7477 r7502  
    399399>>> Article.objects.get(headline='Article 11') in s 
    400400True 
     401 
     402# The 'select' argument to extra() supports names with dashes in them, as long 
     403# as you use values(). 
     404>>> Article.objects.filter(pub_date__year=2008).extra(select={'dashed-value': '1'}).values('headline', 'dashed-value') 
     405[{'headline': u'Article 11', 'dashed-value': 1}, {'headline': u'Article 12', 'dashed-value': 1}] 
     406 
     407# If you use 'select' with extra() and names containing dashes on a query 
     408# that's *not* a values() query, those extra 'select' values will silently be 
     409# ignored. 
     410>>> articles = Article.objects.filter(pub_date__year=2008).extra(select={'dashed-value': '1', 'undashedvalue': '2'}) 
     411>>> articles[0].undashedvalue 
     4122 
    401413"""