Changes between Initial Version and Version 1 of Ticket #33033


Ignore:
Timestamp:
Aug 18, 2021, 2:06:28 PM (3 years ago)
Author:
dennisvang
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #33033

    • Property Summary numpy.nan can be stored in DecimalField but cannot be retrievedNaN can be stored in DecimalField but cannot be retrieved
  • Ticket #33033 – Description

    initial v1  
    11**Description**
    22
    3 If, for whatever reason, a `numpy.nan` value is stored in a `DecimalField` using `sqlite3`, the object cannot be retrieved from the database.
     3If, for whatever reason, a `NaN` value (either `float('nan')`, `math.nan`, or  `numpy.nan`) is stored in a `DecimalField` using `sqlite3`, the object cannot be retrieved from the database.
    44
    55Attempts to do so will raise `TypeError: argument must be int or float`
     
    99**Steps to reproduce**
    1010
    11 1. Create a brand new project using python 3.8.10, numpy 1.21.2, and django 3.2.6 with the default `sqlite3` backend.
     111. Create a brand new project using python 3.8.10 and django 3.2.6 with the default `sqlite3` backend (optionally with numpy 1.21.2).
    1212
    13132. Create a model with a `DecimalField`:
     
    1818}}}
    1919
    20 3. Programmatically create a model instance with `value=numpy.nan`, then try to retrieve the object from the database (or refresh from database).
     203. Programmatically create a model instance with `value=float('nan')` (or `math.nan`, or `numpy.nan`), then try to retrieve the object from the database (or refresh from database).
    2121
    2222{{{
    23 obj = MyModel.objects.create(value=numpy.nan)
     23obj = MyModel.objects.create(value=float('nan'))
    2424# the following raises a "TypeError: argument must be int or float"
    2525obj.refresh_from_db() 
Back to Top