'Doing exclude() on a foreign model after annotate() doesn\'t crash.'

def test_ticket17424(self):

    all_books = list(Book.objects.values_list('pk', flat=True).order_by('pk'))
    annotated_books = Book.objects.order_by('pk').annotate(one=Count('id'))
    excluded_books = annotated_books.exclude(publisher__name='__UNLIKELY_VALUE__')
    str(excluded_books.query)
    self.assertQuerysetEqual(excluded_books, all_books, (lambda x: x.pk))
    self.assertIsNone(annotated_books.query.alias_map['aggregation_book'].join_type)
    self.assertIsNone(excluded_books.query.alias_map['aggregation_book'].join_type)
