#34421 closed Bug (fixed)

QuerySet.update() on querysets in descending order by annotations.

Reported by: WE1 Owned by: WE1
Component: Database layer (models, ORM) Version: 4.1
Severity: Normal Keywords: update, order_by
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

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.

Change History (3)

comment:1 by Mariusz Felisiak, 21 months ago

Has patch: set
Triage Stage: UnreviewedAccepted

comment:2 by Mariusz Felisiak, 21 months ago

Triage Stage: AcceptedReady for checkin

comment:3 by Mariusz Felisiak <felisiak.mariusz@…>, 21 months ago

Resolution: fixed
Status: assignedclosed

In 2ffa815c:

Fixed #34421 -- Fixed QuerySet.update() on querysets in descending order by annotations.

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