Re: [Django] #33954: "NaN" can be stored in DecimalField but cannot be retrieved (was: NaN can be stored in DecimalField but cannot be retrieved)

1 view
Skip to first unread message

Django

unread,
Aug 25, 2022, 5:23:44 AM8/25/22
to django-...@googlegroups.com
#33954: "NaN" can be stored in DecimalField but cannot be retrieved
-------------------------------------+-------------------------------------
Reporter: Xabier Bello | Owner: nobody
Type: | Status: new
Cleanup/optimization |
Component: Database layer | Version: 4.1
(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):

* status: closed => new
* type: Bug => Cleanup/optimization
* resolution: invalid =>
* stage: Unreviewed => Accepted


Comment:

> Notice that I'm using the Model validation, if I'm not mistaken and it
refers to creating objects with `MyModel.objects.create`

Not really, `.create()` and `.save()` don't call `full_clean()` (see
[https://docs.djangoproject.com/en/4.1/ref/models/instances/#validating-
objects docs]). We added extra guards in #33033 because on some databases
(SQLite and PostgreSQL) `NaN` values are accepted without raising any
database-level errors.

I agree that we should add the same checks for `"nan"` strings.

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

Reply all
Reply to author
Forward
0 new messages