summaryrefslogtreecommitdiff
path: root/tests/annotations
diff options
context:
space:
mode:
authorMariusz Felisiak <felisiak.mariusz@gmail.com>2017-03-29 06:47:07 +0200
committerGitHub <noreply@github.com>2017-03-29 06:47:07 +0200
commit1d070d027c218285b66c0bde8079034b33a87f11 (patch)
treebd404252d692e810e421c47bdf76f9d9e75d864a /tests/annotations
parentb59c0d722d9b498e840feea6e2e88238d3dadf54 (diff)
Fixed #25414 -- Fixed QuerySet.annotate() with pk in values() on MySQL.
Thanks Tim Graham and Simon Charette for the reviews.
Diffstat (limited to 'tests/annotations')
-rw-r--r--tests/annotations/tests.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/tests/annotations/tests.py b/tests/annotations/tests.py
index b149ddf46c..2ad395e65c 100644
--- a/tests/annotations/tests.py
+++ b/tests/annotations/tests.py
@@ -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,