diff options
| author | Carl Meyer <carl@oddbird.net> | 2010-10-09 20:10:00 +0000 |
|---|---|---|
| committer | Carl Meyer <carl@oddbird.net> | 2010-10-09 20:10:00 +0000 |
| commit | b6223d302036ed46db80115906e2230411bc91f6 (patch) | |
| tree | 9939c9fdff730bcf9a21fea823a645fd90573bf5 /tests | |
| parent | 62dfe54d70892a50e867712eff465bdc30762906 (diff) | |
[1.2.X] Added sanity-checking of annotation alias names. Backport of [14092] from trunk.
git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.2.X@14093 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/regressiontests/aggregation_regress/tests.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/tests/regressiontests/aggregation_regress/tests.py b/tests/regressiontests/aggregation_regress/tests.py index 51f439c5a1..786431420d 100644 --- a/tests/regressiontests/aggregation_regress/tests.py +++ b/tests/regressiontests/aggregation_regress/tests.py @@ -481,6 +481,14 @@ class AggregationTests(TestCase): lambda b: b.name ) + def test_duplicate_alias(self): + # Regression for #11256 - duplicating a default alias raises ValueError. + self.assertRaises(ValueError, Book.objects.all().annotate, Avg('authors__age'), authors__age__avg=Avg('authors__age')) + + def test_field_name_conflict(self): + # 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_pickle(self): # Regression for #10197 -- Queries with aggregates can be pickled. # First check that pickling is possible at all. No crash = success |
