#34437 closed Bug (fixed)

values() doesn't mention annotations as valid choices on resolving error

Reported by: Simon Charette Owned by: Simon Charette
Component: Database layer (models, ORM) Version: 4.1
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

When doing

Book.objects.annotate(annotation=Value(1)).values("annotation_type")

The resulting FieldError doesn't mention annotation as a valid choice

FieldError: Cannot resolve keyword 'annotation_typo' into field. Choices are: age, book, book_contact_set, friends, id, name

Change History (2)

comment:1 by Mariusz Felisiak, 20 months ago

Owner: changed from nobody to Simon Charette
Triage Stage: UnreviewedAccepted

comment:2 by GitHub <noreply@…>, 20 months ago

Resolution: fixed
Status: assignedclosed

In cb137929:

Fixed #34437 -- Made values() resolving error mention selected annotations.

While the add_fields() call from set_values() does trigger validation it
does so after annotations are masked resulting in them being excluded
from the choices of valid options surfaced through a FieldError.

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