#10248 closed (fixed)
Calling .dates on a annotated queryset gives wrong sql
Reported by: | oyvind | Owned by: | |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | dev |
Severity: | Keywords: | annotate dates queryset | |
Cc: | Triage Stage: | Accepted | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Example models
class Photo(models.Model): title = models.CharField(max_length=30) class Gallery(models.Model): title = models.CharField(max_length=30) photos = models.ManyToManyField(Photo) date_published = models.DateField()
Query:
from django.db import connection from django.db.models import Count Gallery.objects.dates('date_published', 'year') print connection.queries[-1] Gallery.objects.annotate(photo_count=Count('photos__id')).dates('date_published', 'year') print connection.queries[-1]
Attachments (1)
Change History (7)
comment:1 by , 16 years ago
Component: | Uncategorized → ORM aggregation |
---|---|
Owner: | removed |
by , 16 years ago
Attachment: | annotate-dates.diff added |
---|
comment:2 by , 16 years ago
Has patch: | set |
---|---|
Triage Stage: | Unreviewed → Accepted |
comment:3 by , 16 years ago
Version: | 1.0 → SVN |
---|
comment:4 by , 16 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
comment:5 by , 16 years ago
I'm on a roll tonight - that's 2 messed up commit messages in a row. Apologies to Oyvind Saltvik for misattributing the original report to Alex in the commit message. Still giving thanks to Alex for the patch, though :-)
comment:6 by , 12 years ago
Component: | ORM aggregation → Database layer (models, ORM) |
---|
Note:
See TracTickets
for help on using tickets.
(In [9839]) Fixed #10248 -- Corrected handling of the GROUP BY clause when using a DateQuerySet. Thanks to Alex Gaynor for the report and patch.