mirror of
https://github.com/django/django.git
synced 2025-08-04 02:48:35 +00:00
Fixed #25414 -- Fixed QuerySet.annotate() with pk in values() on MySQL.
Thanks Tim Graham and Simon Charette for the reviews.
This commit is contained in:
parent
b59c0d722d
commit
1d070d027c
2 changed files with 18 additions and 5 deletions
|
@ -297,6 +297,12 @@ class NonAggregateAnnotationTestCase(TestCase):
|
|||
self.assertEqual(book['other_rating'], 4)
|
||||
self.assertEqual(book['other_isbn'], '155860191')
|
||||
|
||||
def test_values_with_pk_annotation(self):
|
||||
# annotate references a field in values() with pk
|
||||
publishers = Publisher.objects.values('id', 'book__rating').annotate(total=Sum('book__rating'))
|
||||
for publisher in publishers.filter(pk=self.p1.pk):
|
||||
self.assertEqual(publisher['book__rating'], publisher['total'])
|
||||
|
||||
def test_defer_annotation(self):
|
||||
"""
|
||||
Deferred attributes can be referenced by an annotation,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue