@skipUnlessDBFeature("allows_group_by_pk")
    def test_aggregate_duplicate_columns_select_related(self):
        # And select_related()
        results = Book.objects.select_related('contact').annotate(
            num_authors=Count('authors'))
        grouping, gb_params = results.query.get_compiler(using='default').get_grouping([], [])
        self.assertEqual(len(grouping), 1)
        assert 'id' in grouping[0]
        assert 'name' not in grouping[0]
        assert 'contact' not in grouping[0]

        # The query group_by property should also only show the `id`.
        self.assertEqual(results.query.group_by, [('aggregation_regress_book', 'id')])

        # Ensure that we get correct results.
        self.assertEqual(
            [(b.name, b.num_authors) for b in results.order_by('name')],
            [
                ('Artificial Intelligence: A Modern Approach', 2),
                ('Paradigms of Artificial Intelligence Programming: Case Studies in Common Lisp', 1),
                ('Practical Django Projects', 1),
                ('Python Web Development with Django', 3),
                ('Sams Teach Yourself Django in 24 Hours', 1),
                ('The Definitive Guide to Django: Web Development Done Right', 2)
            ]
        )
dataset/ETHPy150Open cloudera/hue/desktop/core/ext-py/Django-1.6.10/tests/aggregation_regress/tests.py/AggregationTests.test_aggregate_duplicate_columns_select_related/original