      def test_pickle(self):
          # Regression for #10197 -- Queries with aggregates can be pickled.
          # First check that pickling is possible at all. No crash = success
          qs = Book.objects.annotate(num_authors=Count('authors'))
          out = pickle.dumps(qs)
  
          # Then check that the round trip works.
          query = qs.query.get_compiler(qs.db).as_sql()[0]
          qs2 = pickle.loads(pickle.dumps(qs))
          self.assertEqual(
 
</s> remove             self.cols[node] = (change_map.get(col[0], col[0]), col[1])
 </s> add             if hasattr(col, "relabel_aliases"):
                col.relabel_aliases(change_map)
            else:
                self.cols[node] = (change_map.get(col[0], col[0]), col[1]) </s> remove import pickle

from django.db import connection, models, DEFAULT_DB_ALIAS
from django.conf import settings
 </s> add from django.db import models </s> remove from regressiontests.aggregation_regress.models import *
 </s> add from models import Author, Book, Publisher, Clues, Entries, HardbackBook </s> remove from django.db import DEFAULT_DB_ALIAS
 </s> add 
        pickle.dumps(qs)
      def test_pickle(self):
          # Regression for #10197 -- Queries with aggregates can be pickled.
          # First check that pickling is possible at all. No crash = success
          qs = Book.objects.annotate(num_authors=Count('authors'))
        pickle.dumps(qs)
  
          # Then check that the round trip works.
          query = qs.query.get_compiler(qs.db).as_sql()[0]
          qs2 = pickle.loads(pickle.dumps(qs))
          self.assertEqual(
keep keep keep keep replace keep keep keep keep keep
 Fixed #14754 -- corrected using an aggregate in an F expressions when that queryset is later used in a subquery.  Thanks to master for the patch.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@14681 bcc190cf-cafb-0310-a4f2-bffc1f526a37 
tests/regressiontests/aggregation_regress/tests.py