Opened 7 years ago

Closed 14 months ago

#11671 closed Bug (wontfix)

Aggregations add extra values to ValuesQuerySets :: another usecase

Reported by: richard@… Owned by:
Component: Database layer (models, ORM) Version: master
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 Changed 7 years ago by Alex Gaynor

Needs documentation: unset
Needs tests: unset
Patch needs improvement: unset
Triage Stage: UnreviewedAccepted

comment:2 Changed 7 years ago by Thejaswi Puthraya

Component: UncategorizedORM aggregation
Owner: nobody deleted

comment:3 Changed 6 years ago by fetzig

Cc: klemens@… added

comment:4 Changed 6 years ago by fetzig

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 Changed 5 years ago by Julien Phalip

Severity: Normal
Type: Bug

comment:6 Changed 5 years ago by anonymous

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 Changed 5 years ago by Aymeric Augustin

UI/UX: unset

Change UI/UX from NULL to False.

comment:8 Changed 5 years ago by Aymeric Augustin

Easy pickings: unset

Change Easy pickings from NULL to False.

comment:9 Changed 4 years ago by Anssi Kääriäinen

Component: ORM aggregationDatabase layer (models, ORM)

comment:10 Changed 2 years ago by jorgecarleitao

Cc: jorgecarleitao@… added

comment:11 Changed 14 months ago by Tim Graham

Keywords: QuerySet.extra added

comment:12 Changed 14 months ago by Tim Graham

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