Code

Ticket #10132: 10132-test.diff

File 10132-test.diff, 832 bytes (added by Glenn, 5 years ago)
Line 
1Index: tests/regressiontests/queries/models.py
2===================================================================
3--- tests/regressiontests/queries/models.py     (revision 9734)
4+++ tests/regressiontests/queries/models.py     (working copy)
5@@ -1028,6 +1028,12 @@
6 >>> Annotation.objects.filter(notes__in=Note.objects.filter(note="n1").values_list('note').values('id'))
7 [<Annotation: a1>]
8 
9+Bug #10132 -- QuerySet values() should work on extra(select) fields
10+>>> from django.db.models import Count
11+>>> test = Item.objects.extra(select={"note_alias": "note_id"}).values("note_alias")
12+>>> test.order_by("note_alias").annotate(Count("id"))
13+[{'note_alias': 1, 'id__count': 2}, {'note_alias': 2, 'id__count': 1}, {'note_alias': 3, 'id__count': 3}]
14+
15 """}
16 
17 # In Python 2.3 and the Python 2.6 beta releases, exceptions raised in __len__