#19426 closed Bug (fixed)
EmptyQuerySet.distinct does not have the same signature as QuerySet.distinct()
Reported by: | anonymous | Owned by: | Claude Paroz |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | dev |
Severity: | Normal | Keywords: | |
Cc: | Benjamin Dauvergne, hongshuning@… | Triage Stage: | Ready for checkin |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | yes | UI/UX: | no |
Description
QuerySet.distinct is:
def distinct(self, *field_names):
but EmptyQuerySet.distinct is :
def distinct(self, fields=None):
when called like this:
qs = qs.distinct('field1', 'field2')
if qs is empty then it raises:
TypeError: distinct() takes at most 2 arguments (3 given)
Attachments (1)
Change History (10)
comment:1 by , 12 years ago
Cc: | added |
---|
comment:2 by , 12 years ago
Component: | Uncategorized → Database layer (models, ORM) |
---|---|
Easy pickings: | set |
Triage Stage: | Unreviewed → Accepted |
Type: | Uncategorized → Cleanup/optimization |
comment:3 by , 12 years ago
Owner: | changed from | to
---|---|
Type: | Cleanup/optimization → Bug |
bdauvergne, you are the reporter, right?
by , 12 years ago
Attachment: | 19426.diff added |
---|
comment:5 by , 12 years ago
Triage Stage: | Accepted → Ready for checkin |
---|
@claudep, looking at #6422 it seems the chosen approach was ignoring the fields kwarg altogether. I think we should stick to that here also.
All queries tests pass on Python 2.7.3 SQlite so I'm marking as RFC.
comment:6 by , 12 years ago
There is another ticket which does a larger refactor of the emptyqs class, see https://code.djangoproject.com/ticket/19184
comment:7 by , 12 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
comment:8 by , 12 years ago
I committed the fix without the test, as #19184 will probably remove this part anyway.
Easy enough to keep the fields kwarg while allowing *args as this is essentially a noop for EmptyQuerySet