#11890: Defer/only + annotate is broken
---------------------------------------------------+------------------------
Reporter: [email protected] | Owner: ruosteinen
Status: assigned | Milestone: 1.2
Component: Database layer (models, ORM) | Version: SVN
Resolution: | Keywords:
Stage: Accepted | Has_patch: 1
Needs_docs: 0 | Needs_tests: 0
Needs_better_patch: 1 |
---------------------------------------------------+------------------------
Changes (by ruosteinen):
* needs_better_patch: 0 => 1
Comment:
Noticed an extra error when using select_related as well. For models:
{{{
from django.db import models
class Person(models.Model):
first_name = models.CharField(max_length=200)
last_name = models.CharField(max_length=50)
best_friend = models.ForeignKey('self', blank=True, null=True,
editable=False)
nick_name = models.CharField(max_length=50, blank=True, null=True)
class Candy(models.Model):
owner = models.ForeignKey(Person, related_name="candies")
qty = models.PositiveIntegerField(default=0)
from django.db.models import Sum;
Person.objects.all().delete()
Candy.objects.all().delete()
p = Person.objects.create(first_name='Mr', last_name='Egotistic')
p.best_friend = p
p.id = 1 # For determinism
p.save()
creations = [Candy(pk=n, owner_id=p.pk, qty=42).save() for n in
xrange(10)]
assert
Person.objects.annotate(Sum('candies__qty')).select_related('best_friend').defer('first_name','best_friend__nick_name').get(pk=p.pk).candies__qty__sum
== 378
}}}
Indexing goes wrong in django.db.sql.compiler even when applying this
patch. I'll work on it but in the meantime I'll add a diff for regression.
--
Ticket URL: <http://code.djangoproject.com/ticket/11890#comment:6>
Django <http://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en.