[Django] #34480: Annotating with Chr raises ValueError

11 views
Skip to first unread message

Django

unread,
Apr 10, 2023, 11:20:24 AM4/10/23
to django-...@googlegroups.com
#34480: Annotating with Chr raises ValueError
-------------------------------------+-------------------------------------
Reporter: Jacob | Owner: Jacob Walls
Walls |
Type: Bug | Status: assigned
Component: Database | Version: 4.2
layer (models, ORM) |
Severity: Normal | Keywords:
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
{{{
>>> Author.objects.annotate(first_letter=Chr(Value(77)))
File "/Users/.../geoguard/.venv/lib/python3.9/site-
packages/django/db/models/expressions.py", line 369, in <lambda>
else int(value)
ValueError: invalid literal for int() with base 10: 'M'
}}}

I'm suggesting in `Chr` we can set `output_field = CharField()` to prevent
this.

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

Django

unread,
Apr 10, 2023, 11:20:51 AM4/10/23
to django-...@googlegroups.com
#34480: Annotating with Chr raises ValueError
-------------------------------------+-------------------------------------
Reporter: Jacob Walls | Owner: Jacob

| Walls
Type: Bug | Status: assigned
Component: Database layer | Version: 4.2
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Description changed by Jacob Walls:

Old description:

> {{{
> >>> Author.objects.annotate(first_letter=Chr(Value(77)))
> File "/Users/.../geoguard/.venv/lib/python3.9/site-
> packages/django/db/models/expressions.py", line 369, in <lambda>
> else int(value)
> ValueError: invalid literal for int() with base 10: 'M'
> }}}
>
> I'm suggesting in `Chr` we can set `output_field = CharField()` to
> prevent this.

New description:

{{{
>>> Author.objects.annotate(first_letter=Chr(Value(77)))
File "/Users/.../.../.venv/lib/python3.9/site-


packages/django/db/models/expressions.py", line 369, in <lambda>
else int(value)
ValueError: invalid literal for int() with base 10: 'M'
}}}

I'm suggesting in `Chr` we can set `output_field = CharField()` to prevent
this.

--

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

Django

unread,
Apr 10, 2023, 12:57:52 PM4/10/23
to django-...@googlegroups.com
#34480: Annotating with Chr raises ValueError
-------------------------------------+-------------------------------------
Reporter: Jacob Walls | Owner: Jacob
| Walls
Type: Bug | Status: assigned
Component: Database layer | Version: 4.2
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted

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

* stage: Unreviewed => Accepted


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

Django

unread,
Apr 10, 2023, 4:33:12 PM4/10/23
to django-...@googlegroups.com
#34480: Annotating with Chr raises ValueError
-------------------------------------+-------------------------------------
Reporter: Jacob Walls | Owner: Jacob
| Walls
Type: Bug | Status: assigned
Component: Database layer | Version: 4.2
(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 Jacob Walls):

* has_patch: 0 => 1


Comment:

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

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

Django

unread,
Apr 10, 2023, 11:58:12 PM4/10/23
to django-...@googlegroups.com
#34480: Annotating with Chr raises ValueError
-------------------------------------+-------------------------------------
Reporter: Jacob Walls | Owner: Jacob
| Walls
Type: Bug | Status: assigned
Component: Database layer | Version: 4.2
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | 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/34480#comment:4>

Django

unread,
Apr 11, 2023, 1:51:08 AM4/11/23
to django-...@googlegroups.com
#34480: Annotating with Chr raises ValueError
-------------------------------------+-------------------------------------
Reporter: Jacob Walls | Owner: Jacob
| Walls
Type: Bug | Status: closed

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

Keywords: | 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:"c3d7a71f836f7cfe8fa90dd9ae95b37b660d5aae" c3d7a71f]:
{{{
#!CommitTicketReference repository=""
revision="c3d7a71f836f7cfe8fa90dd9ae95b37b660d5aae"
Fixed #34480 -- Fixed crash of annotations with Chr().
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/34480#comment:5>

Reply all
Reply to author
Forward
0 new messages