[Django] #26185: values_list throws interesting error when ordering by an extra column

12 views
Skip to first unread message

Django

unread,
Feb 8, 2016, 11:10:02 AM2/8/16
to django-...@googlegroups.com
#26185: values_list throws interesting error when ordering by an extra column
----------------------------------------------+--------------------
Reporter: srkunze | Owner: nobody
Type: Bug | Status: new
Component: Database layer (models, ORM) | Version: 1.8
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
----------------------------------------------+--------------------
{{{
MyModel.objects.extra(select={'my_column':
'adas'}).order_by('my_column').values_list('id', flat=True)

ProgrammingError: column "adas" does not exist
LINE 1: ...arch3_beleg"."id" FROM "modarch3_beleg" ORDER BY (adas) ASC ...
}}}

There's already a similar ticket (but it's closed as fixed)
https://code.djangoproject.com/ticket/14930

--
Ticket URL: <https://code.djangoproject.com/ticket/26185>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Feb 8, 2016, 11:28:57 AM2/8/16
to django-...@googlegroups.com
#26185: values_list throws interesting error when ordering by an extra column
-------------------------------------+-------------------------------------
Reporter: srkunze | Owner: nobody
Type: Bug | Status: closed
Component: Database layer | Version: 1.8
(models, ORM) |
Severity: Normal | Resolution: wontfix
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by timgraham):

* status: new => closed
* needs_better_patch: => 0
* resolution: => wontfix
* needs_tests: => 0
* needs_docs: => 0


Comment:

As noted
[https://docs.djangoproject.com/en/1.9/ref/models/querysets/#django.db.models.query.QuerySet.extra
in the docs], we aren't fixed bugs that involved `QuerySet.extra()`.

--
Ticket URL: <https://code.djangoproject.com/ticket/26185#comment:1>

Django

unread,
Feb 9, 2016, 3:41:27 AM2/9/16
to django-...@googlegroups.com
#26185: values_list throws interesting error when ordering by an extra column
-------------------------------------+-------------------------------------
Reporter: srkunze | Owner: nobody

Type: Bug | Status: closed
Component: Database layer | Version: 1.8
(models, ORM) |
Severity: Normal | Resolution: wontfix
Keywords: | Triage Stage:
| Unreviewed

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by srkunze):

How are we supposed to construct such queries then (asking as noted in the
docs)?


As usual the given example is minimal: so the actual **working** flow goes
like this:
{{{
# create complex queryset
... more code
# add extra column
... more code
# add order (maybe referring to extra column)
... more code
# create values_list queryset
... more code
# evaluate <<<< crash
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/26185#comment:2>

Django

unread,
Feb 9, 2016, 7:11:17 AM2/9/16
to django-...@googlegroups.com
#26185: values_list throws interesting error when ordering by an extra column
-------------------------------------+-------------------------------------
Reporter: srkunze | Owner: nobody

Type: Bug | Status: closed
Component: Database layer | Version: 1.8
(models, ORM) |
Severity: Normal | Resolution: wontfix
Keywords: | Triage Stage:
| Unreviewed

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by timgraham):

If you have trouble using the
[https://docs.djangoproject.com/en/stable/ref/models/expressions/
expressions API], please ask using our support channels:
TicketClosingReasons/UseSupportChannels.

--
Ticket URL: <https://code.djangoproject.com/ticket/26185#comment:3>

Django

unread,
Feb 9, 2016, 7:17:18 AM2/9/16
to django-...@googlegroups.com
#26185: values_list throws interesting error when ordering by an extra column
-------------------------------------+-------------------------------------
Reporter: srkunze | Owner: nobody

Type: Bug | Status: closed
Component: Database layer | Version: 1.8
(models, ORM) |
Severity: Normal | Resolution: wontfix
Keywords: | Triage Stage:
| Unreviewed

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by srkunze):

I was able to rewrite the extra statement using a combination of
Expression (for select) and extra (for where). So, I think we are set for
now.

If you really consider deprecating extra, there would need to be a
facility to add custom where clauses.

--
Ticket URL: <https://code.djangoproject.com/ticket/26185#comment:4>

Django

unread,
Feb 9, 2016, 7:22:55 AM2/9/16
to django-...@googlegroups.com
#26185: values_list throws interesting error when ordering by an extra column
-------------------------------------+-------------------------------------
Reporter: srkunze | Owner: nobody

Type: Bug | Status: closed
Component: Database layer | Version: 1.8
(models, ORM) |
Severity: Normal | Resolution: wontfix
Keywords: | Triage Stage:
| Unreviewed

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by srkunze):

@timgraham thanks for pointing me at the docs. :)

--
Ticket URL: <https://code.djangoproject.com/ticket/26185#comment:5>

Reply all
Reply to author
Forward
0 new messages