Changeset 7502
- Timestamp:
- 04/28/08 16:15:05 (3 months ago)
- Files:
-
- django/trunk/django/db/models/sql/query.py (modified) (1 diff)
- django/trunk/tests/modeltests/basic/models.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/trunk/django/db/models/sql/query.py
r7499 r7502 395 395 """ 396 396 qn = self.quote_name_unless_alias 397 result = ['(%s) AS %s' % (col, alias) for alias, col in self.extra_select.iteritems()] 397 qn2 = self.connection.ops.quote_name 398 result = ['(%s) AS %s' % (col, qn2(alias)) for alias, col in self.extra_select.iteritems()] 398 399 aliases = set(self.extra_select.keys()) 399 400 if with_aliases: django/trunk/tests/modeltests/basic/models.py
r7477 r7502 399 399 >>> Article.objects.get(headline='Article 11') in s 400 400 True 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 412 2 401 413 """
