#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 <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/010701876bc16242-00ff8bc2-e691-4caf-83e3-7174c1775795-000000%40eu-central-1.amazonses.com.

Reply via email to