#11789 closed Bug (fixed)
Aggregates ignore none()
Reported by: | Alex Robbins | Owned by: | noah |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | 1.1 |
Severity: | Normal | Keywords: | aggregates |
Cc: | Triage Stage: | Accepted | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | yes |
Easy pickings: | no | UI/UX: | no |
Description
Model.objects.all().aggregate(Max('field'))
and
Model.objects.none().aggregate(Max('field'))
seem to return the same thing. Aggregates pay attention to filters, but they seem to ignore the none() method. This isn't a common use, so it might not be worth fixing, except for correctness.
Attachments (1)
Change History (13)
comment:1 by , 15 years ago
milestone: | → 1.2 |
---|---|
Triage Stage: | Unreviewed → Accepted |
by , 15 years ago
Attachment: | 11789.diff added |
---|
comment:2 by , 15 years ago
Has patch: | set |
---|---|
Owner: | changed from | to
Status: | new → assigned |
comment:3 by , 15 years ago
Triage Stage: | Accepted → Ready for checkin |
---|
comment:4 by , 15 years ago
Patch needs improvement: | set |
---|---|
Triage Stage: | Ready for checkin → Accepted |
I'm not sure that we want aggregates to return None
; I think aggregates on an empty qs should raise an exception: "in the face of ambiguity, refuses the temptation to guess." Unless anyone's got a good reason to do it like this, let's make aggregate
raise an exception on the empty set.
comment:5 by , 15 years ago
milestone: | 1.2 → 1.3 |
---|---|
Triage Stage: | Accepted → Design decision needed |
I'm not sure I agree that this should raise an exception. Author.objects.none() is no different to Author.objects.filter(name="something that does not exist"); I don't see why the behaviour should be any different.
Either way, not critical for 1.2
comment:6 by , 15 years ago
Component: | Database layer (models, ORM) → ORM aggregation |
---|
comment:7 by , 14 years ago
Triage Stage: | Design decision needed → Accepted |
---|
Russell is questioning the implementation, not the functionality. (I agree with no exception -- it's not an error). Moving back to "accepted"
comment:8 by , 14 years ago
Severity: | → Normal |
---|---|
Type: | → Bug |
comment:10 by , 13 years ago
Easy pickings: | unset |
---|
Sorry for the error when giving credits in the commit message. Thanks goes to noah for providing the patch fixing this issue.
comment:12 by , 12 years ago
Component: | ORM aggregation → Database layer (models, ORM) |
---|
A patch for this ticket