[Django] #34421: QuerySet.update() on querysets in descending order by annotations.

3 views
Skip to first unread message

Django

unread,
Mar 17, 2023, 1:25:58 PM3/17/23
to django-...@googlegroups.com
#34421: QuerySet.update() on querysets in descending order by annotations.
-------------------------------------+-------------------------------------
Reporter: WE1 | Owner: WE1
Type: Bug | Status: assigned
Component: Database | Version: 4.1
layer (models, ORM) |
Severity: Normal | Keywords: update,order_by
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
When I execute
{{{
Model.objects.annotate(message_length=Length('message')).order_by('-message_length').update(text="Can
I come on board?")
}}}

I get the error

{{{
FieldError: Cannot resolve keyword 'message_length' into field. Choices
are: message, id, text, x
}}}

because the code ignores the descending case.

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

Django

unread,
Mar 17, 2023, 3:06:26 PM3/17/23
to django-...@googlegroups.com
#34421: QuerySet.update() on querysets in descending order by annotations.
-------------------------------------+-------------------------------------
Reporter: WE1 | Owner: WE1
Type: Bug | Status: assigned
Component: Database layer | Version: 4.1
(models, ORM) |
Severity: Normal | Resolution:
Keywords: update,order_by | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* has_patch: 0 => 1
* stage: Unreviewed => Accepted


Comment:

[https://github.com/django/django/pull/16657 PR]

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

Django

unread,
Mar 17, 2023, 3:21:19 PM3/17/23
to django-...@googlegroups.com
#34421: QuerySet.update() on querysets in descending order by annotations.
-------------------------------------+-------------------------------------
Reporter: WE1 | Owner: WE1
Type: Bug | Status: assigned
Component: Database layer | Version: 4.1
(models, ORM) |
Severity: Normal | Resolution:
Keywords: update,order_by | Triage Stage: Ready for
| checkin

Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* stage: Accepted => Ready for checkin


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

Django

unread,
Mar 18, 2023, 8:55:09 AM3/18/23
to django-...@googlegroups.com
#34421: QuerySet.update() on querysets in descending order by annotations.
-------------------------------------+-------------------------------------
Reporter: WE1 | Owner: WE1
Type: Bug | Status: closed

Component: Database layer | Version: 4.1
(models, ORM) |
Severity: Normal | Resolution: fixed

Keywords: update,order_by | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak <felisiak.mariusz@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"2ffa815c734e12262a3cb8ce5664f297128ae47f" 2ffa815c]:
{{{
#!CommitTicketReference repository=""
revision="2ffa815c734e12262a3cb8ce5664f297128ae47f"
Fixed #34421 -- Fixed QuerySet.update() on querysets in descending order
by annotations.
}}}

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

Reply all
Reply to author
Forward
0 new messages