Opened 3 years ago

Closed 3 years ago

Last modified 4 days ago

#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 (3)

comment:1 by Mariusz Felisiak, 3 years ago

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

comment:2 by GitHub <noreply@…>, 3 years 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.

comment:3 by Jacob Walls <jacobtylerwalls@…>, 4 days ago

In dce1b9c:

Fixed #36480 -- Made values() resolving error mention unselected aliases.

Follow-up to cb13792938f2c887134eb6b5164d89f8d8f9f1bd. Refs #34437.

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