'QuerySet.distinct(\'field\', ...) works'

@skipUnlessDBFeature('can_distinct_on_fields')
def test_basic_distinct_on(self):

    qsets = ((Staff.objects.distinct().order_by('name'), ['<Staff:    p1>', '<Staff:    p1>', '<Staff:    p2>', '<Staff:    p3>']), (Staff.objects.distinct('name').order_by('name'), ['<Staff:    p1>', '<Staff:    p2>', '<Staff:    p3>']), (Staff.objects.distinct('organisation').order_by('organisation', 'name'), ['<Staff:    p1>', '<Staff:    p1>']), (Staff.objects.distinct('name', 'organisation').order_by('name', 'organisation'), ['<Staff:    p1>', '<Staff:    p1>', '<Staff:    p2>', '<Staff:    p3>']), (Celebrity.objects.filter(fan__in=[self.fan1, self.fan2, self.fan3]).distinct('name').order_by('name'), ['<Celebrity:    c1>', '<Celebrity:    c2>']), ((Celebrity.objects.filter(fan__in=[self.fan1, self.fan2]).distinct('name').order_by('name') | Celebrity.objects.filter(fan__in=[self.fan3]).distinct('name').order_by('name')), ['<Celebrity:    c1>', '<Celebrity:    c2>']), (StaffTag.objects.distinct('staff', 'tag'), ['<StaffTag:    t1    ->    p1>']), (Tag.objects.order_by('parent__pk', 'pk').distinct('parent'), ['<Tag:    t2>', '<Tag:    t4>', '<Tag:    t1>']), (StaffTag.objects.select_related('staff').distinct('staff__name').order_by('staff__name'), ['<StaffTag:    t1    ->    p1>']), (Staff.objects.distinct('id').order_by('id', 'coworkers__name').values_list('id', 'coworkers__name'), [str_prefix("(1,    %(_)s'p2')"), str_prefix("(2,    %(_)s'p1')"), str_prefix("(3,    %(_)s'p1')"), '(4,    None)']))
    for (qset, expected) in qsets:
        self.assertQuerysetEqual(qset, expected)
        self.assertEqual(qset.count(), len(expected))
    base_qs = Celebrity.objects.all()
    self.assertRaisesMessage(AssertionError, 'Cannot    combine    queries    with    different    distinct    fields.', (lambda : (base_qs.distinct('id') & base_qs.distinct('name'))))
    c1 = Celebrity.objects.distinct('greatest_fan__id', 'greatest_fan__fan_of')
    self.assertIn('OUTER    JOIN', str(c1.query))
    c2 = c1.distinct('pk')
    self.assertNotIn('OUTER    JOIN', str(c2.query))
