summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorCarl Meyer <carl@oddbird.net>2010-10-10 08:06:39 +0000
committerCarl Meyer <carl@oddbird.net>2010-10-10 08:06:39 +0000
commit700c5a3dfe46155ae367345eb4e7a04013bb6548 (patch)
tree19ae93689069b5f1afdb48e20a86cdb35abe04ed /tests
parent4395b6575b4b18f287ce7eeea81a40205c1c5a40 (diff)
[1.2.X] Refs #11256 -- Extended the annotation field name conflict check to cover m2ms and reverse related descriptors as well. This is needed to actually cover the case raised by #14373. Backport of [14116].
git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.2.X@14117 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests')
-rw-r--r--tests/regressiontests/aggregation_regress/tests.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/tests/regressiontests/aggregation_regress/tests.py b/tests/regressiontests/aggregation_regress/tests.py
index 786431420d..58d0b2748f 100644
--- a/tests/regressiontests/aggregation_regress/tests.py
+++ b/tests/regressiontests/aggregation_regress/tests.py
@@ -489,6 +489,14 @@ class AggregationTests(TestCase):
# Regression for #11256 - providing an aggregate name that conflicts with a field name on the model raises ValueError
self.assertRaises(ValueError, Author.objects.annotate, age=Avg('friends__age'))
+ def test_m2m_name_conflict(self):
+ # Regression for #11256 - providing an aggregate name that conflicts with an m2m name on the model raises ValueError
+ self.assertRaises(ValueError, Author.objects.annotate, friends=Count('friends'))
+
+ def test_reverse_relation_name_conflict(self):
+ # Regression for #11256 - providing an aggregate name that conflicts with a reverse-related name on the model raises ValueError
+ self.assertRaises(ValueError, Author.objects.annotate, book_contact_set=Avg('friends__age'))
+
def test_pickle(self):
# Regression for #10197 -- Queries with aggregates can be pickled.
# First check that pickling is possible at all. No crash = success