#36233: Specific DecimalField with integer part longer than 15 digits can be 
stored
but not retrieved on SQLite
-------------------------------------+-------------------------------------
     Reporter:  Orazio               |                    Owner:  Hridesh
                                     |  MG
         Type:  Bug                  |                   Status:  assigned
    Component:  Database layer       |                  Version:  dev
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:
     Keywords:  sqlite, orm,         |             Triage Stage:  Accepted
  decimalfield, invalidoperation     |
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by Hridesh MG):

 * needs_tests:  1 => 0

Comment:

 I've written the following test to reproduce this issue, it can be added
 to `tests/model_fields/test_decimalfield.py`

 {{{#!python
     @skipUnless(
         connection.vendor == "sqlite",
         "Only applies due to SQLite not having a native Decimal type",
     )
     def test_sqlite_precision_rounding_edge_case(self):
         """Test that DecimalField can retrieve values when precision
 exceeds SQLite's 15-digit limit."""
         edge_value = Decimal("9" *
 HighPrecision._meta.get_field("d").max_digits)
         obj = HighPrecision(d=edge_value)
         obj.full_clean()
         obj.save()

         obj.refresh_from_db()
         self.assertIsInstance(obj.d, Decimal)
 }}}

 Corresponding model in `tests/model_fields/models.py`
 {{{#!python
 class HighPrecision(models.Model):
     d = models.DecimalField(max_digits=16, decimal_places=0)

 }}}
-- 
Ticket URL: <https://code.djangoproject.com/ticket/36233#comment:10>
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 visit 
https://groups.google.com/d/msgid/django-updates/010701957a63021d-66033f9e-c840-4808-9204-455f41b38d78-000000%40eu-central-1.amazonses.com.

Reply via email to