[Django] #34437: values() doesn't mention annotations as valid choices on resolving error

12 views
Skip to first unread message

Django

unread,
Mar 25, 2023, 2:32:42 PM3/25/23
to django-...@googlegroups.com
#34437: values() doesn't mention annotations as valid choices on resolving error
-------------------------------------+-------------------------------------
Reporter: Simon | Owner: nobody
Charette |
Type: Bug | Status: assigned
Component: Database | Version: 4.1
layer (models, ORM) |
Severity: Normal | Keywords:
Triage Stage: | Has patch: 1
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
When doing

{{{#!python
Book.objects.annotate(annotation=Value(1)).values("annotation_type")
}}}

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

{{{#!python
FieldError: Cannot resolve keyword 'annotation_typo' into field. Choices
are: age, book, book_contact_set, friends, id, name
}}}

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

Django

unread,
Mar 25, 2023, 2:49:27 PM3/25/23
to django-...@googlegroups.com
#34437: values() doesn't mention annotations as valid choices on resolving error
-------------------------------------+-------------------------------------
Reporter: Simon Charette | Owner: Simon

| Charette
Type: Bug | Status: assigned
Component: Database layer | Version: 4.1
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | 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):

* owner: nobody => Simon Charette
* stage: Unreviewed => Accepted


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

Django

unread,
Mar 25, 2023, 3:22:59 PM3/25/23
to django-...@googlegroups.com
#34437: values() doesn't mention annotations as valid choices on resolving error
-------------------------------------+-------------------------------------
Reporter: Simon Charette | Owner: Simon
| Charette
Type: Bug | Status: closed

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

Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by GitHub <noreply@…>):

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


Comment:

In [changeset:"cb13792938f2c887134eb6b5164d89f8d8f9f1bd" cb137929]:
{{{
#!CommitTicketReference repository=""
revision="cb13792938f2c887134eb6b5164d89f8d8f9f1bd"
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.
}}}

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

Django

unread,
Sep 22, 2025, 8:36:04 AM (23 hours ago) Sep 22
to django-...@googlegroups.com
#34437: values() doesn't mention annotations as valid choices on resolving error
-------------------------------------+-------------------------------------
Reporter: Simon Charette | Owner: Simon
| Charette
Type: Bug | Status: closed
Component: Database layer | Version: 4.1
(models, ORM) |
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Jacob Walls <jacobtylerwalls@…>):

In [changeset:"dce1b9c2de00a3385c029c02dca325f44e7697a4" dce1b9c]:
{{{#!CommitTicketReference repository=""
revision="dce1b9c2de00a3385c029c02dca325f44e7697a4"
Fixed #36480 -- Made values() resolving error mention unselected aliases.

Follow-up to cb13792938f2c887134eb6b5164d89f8d8f9f1bd. Refs #34437.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/34437#comment:3>
Reply all
Reply to author
Forward
0 new messages