﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
11489	annotate fails when values is used via a GeoManager	James Turk	James Turk	"Attempting to do a query like Profile.objects.values('role').annotate(num=Count('id')) does not add a 'num' attribute despite generating seemingly correct SQL.

This was tested against r11247 with PostGIS

{{{
from django.conf import settings
from django.db.models import Manager
from django.contrib.auth.models import User
from django.contrib.gis.db import models
from django.contrib.gis.geos import Point
 
class Profile(models.Model):
    user = models.OneToOneField(User, related_name='profile')
    role = models.CharField(max_length=5, choices=ROLES, default='other')
    # ... extra fields removed ...
 
    objects = models.GeoManager()
    non_geo_manager = Manager()
 
>>> Profile.objects.values('role').annotate(num=Count('id'))._as_sql()
('SELECT U0.""role"", COUNT(U0.""id"") AS num FROM ""people_profile"" U0 GROUP BY U0.""role""', ())
>>> Profile.objects.values('role').annotate(num=Count('id'))
[{'role': u'other'}, {'role': u'dev'}]                                      # notice that 'num' was not added
 
>>> Profile.non_geo_manager.values('role').annotate(num=Count('id'))._as_sql()
('SELECT U0.""role"", COUNT(U0.""id"") AS ""num"" FROM ""people_profile"" U0 GROUP BY U0.""role""', ())
>>> Profile.non_geo_manager.values('role').annotate(num=Count('id'))
[{'num': 19, 'role': u'other'}, {'num': 1, 'role': u'dev'}]                 # num is added as expected

}}}"		closed	GIS	dev		fixed			Unreviewed	1	0	1	0	0	0
