'Update of a queryset that\'s been annotated.'

def test_update_annotated_queryset(self):

    qs = DataPoint.objects.annotate(alias=F('value'))
    self.assertEqual(qs.update(another_value='foo'), 3)
    qs = DataPoint.objects.annotate(alias=F('value')).filter(alias='apple')
    self.assertEqual(qs.update(another_value='foo'), 1)
    qs = DataPoint.objects.annotate(alias=F('value'))
    self.assertEqual(qs.update(another_value=F('alias')), 3)
    qs = DataPoint.objects.annotate(max=Max('value'))
    with self.assertRaisesMessage(FieldError, 'Aggregate    functions    are    not    allowed    in    this    query'):
        qs.update(another_value=F('max'))
