summaryrefslogtreecommitdiff
path: root/tests/aggregation_regress
diff options
context:
space:
mode:
authorFlávio Juvenal <flaviojuvenal@gmail.com>2018-04-12 15:06:43 -0300
committerTim Graham <timograham@gmail.com>2018-04-12 21:15:40 -0400
commite1f13f15512ece2d8ea8c7bf9f704ce4286c2ffa (patch)
tree702ee34597c8ffdbf2dcc28cada606beb9f63f7b /tests/aggregation_regress
parent78f8b80f9b215e50618375adce4c97795dabbb84 (diff)
downloaddjango-e1f13f15512ece2d8ea8c7bf9f704ce4286c2ffa.tar.gz
Fixed #29320 -- Added an exception when an annotation alias matches a ForeignKey attname.
Diffstat (limited to 'tests/aggregation_regress')
-rw-r--r--tests/aggregation_regress/tests.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/tests/aggregation_regress/tests.py b/tests/aggregation_regress/tests.py
index 9c8bac0d21..7f03d66bab 100644
--- a/tests/aggregation_regress/tests.py
+++ b/tests/aggregation_regress/tests.py
@@ -769,6 +769,11 @@ class AggregationTests(TestCase):
with self.assertRaisesMessage(ValueError, msg):
Author.objects.annotate(friends=Count('friends'))
+ def test_fk_attname_conflict(self):
+ msg = "The annotation 'contact_id' conflicts with a field on the model."
+ with self.assertRaisesMessage(ValueError, msg):
+ Book.objects.annotate(contact_id=F('publisher_id'))
+
def test_values_queryset_non_conflict(self):
# Regression for #14707 -- If you're using a values query set, some potential conflicts are avoided.