Opened 15 years ago

Closed 9 years ago

#11671 closed Bug (wontfix)

Aggregations add extra values to ValuesQuerySets :: another usecase

Reported by: richard@… Owned by:
Component: Database layer (models, ORM) Version: dev
Severity: Normal Keywords: QuerySet.extra
Cc: klemens@…, jorgecarleitao@… Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Looking at #10132 I see a similar complaint, however, in this case... the extra.select variable is not included in the values/group_by but is annotated.

>>> qs = TblCdr.objects.extra(select={'billable':'IF(billsec=0,0,1)'},).values('network').annotate(Sum('billable')
... )
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/usr/lib/python2.5/site-packages/django/db/models/query.py", line 580, in annotate
    is_summary=False)
  File "/usr/lib/python2.5/site-packages/django/db/models/sql/query.py", line 1471, in add_aggregate
    field_list, opts, self.get_initial_alias(), False)
  File "/usr/lib/python2.5/site-packages/django/db/models/sql/query.py", line 1737, in setup_joins
    "Choices are: %s" % (name, ", ".join(names)))
FieldError: Cannot resolve keyword 'billable' into field. Choices are: billsec, cause, cli, codec, country_code, dcontext, disposition, dst, duration, end, id, ip, lastapp, network, note, start, supplier

Change History (12)

comment:1 by Alex Gaynor, 15 years ago

Triage Stage: UnreviewedAccepted

comment:2 by Thejaswi Puthraya, 14 years ago

Component: UncategorizedORM aggregation
Owner: nobody removed

comment:3 by fetzig, 14 years ago

Cc: klemens@… added

comment:4 by fetzig, 14 years ago

don't know, but i think i have the same problem #13363. the exception is very similar.

is it complex to create a patch for this, or is it just something nobody did yet?

comment:5 by Julien Phalip, 13 years ago

Severity: Normal
Type: Bug

comment:6 by anonymous, 13 years ago

Version: 1.1SVN

Patching this would be very helpfull as, this feature would be usefull in clustering (geodjango)

e.objects.extra(select={'cluster':'substring(mortons_code for 10)'}).annotate(objects_in_cluster=Count('cluster')).order_by('objects_in_cluster')

same error:

FieldError: Cannot resolve keyword 'cluster' into field. Choices are:


.....

comment:7 by Aymeric Augustin, 12 years ago

UI/UX: unset

Change UI/UX from NULL to False.

comment:8 by Aymeric Augustin, 12 years ago

Easy pickings: unset

Change Easy pickings from NULL to False.

comment:9 by Anssi Kääriäinen, 11 years ago

Component: ORM aggregationDatabase layer (models, ORM)

comment:10 by jorgecarleitao, 10 years ago

Cc: jorgecarleitao@… added

comment:11 by Tim Graham, 9 years ago

Keywords: QuerySet.extra added

comment:12 by Tim Graham, 9 years ago

Resolution: wontfix
Status: newclosed

We are no longer fixing bugs with QuerySet.extra() per discussion on django-developers.

Note: See TracTickets for help on using tickets.
Back to Top