#33232: DecimalField rounding error when upgrading from 3.1 to 3.2
-------------------------------------+-------------------------------------
               Reporter:  Michał     |          Owner:  nobody
  Szczepańczyk                       |
                   Type:  Bug        |         Status:  new
              Component:  Database   |        Version:  3.2
  layer (models, ORM)                |       Keywords:  decimal,
               Severity:  Normal     |  decimalfield, rounding, postgres
           Triage Stage:             |      Has patch:  0
  Unreviewed                         |
    Needs documentation:  0          |    Needs tests:  0
Patch needs improvement:  0          |  Easy pickings:  0
                  UI/UX:  0          |
-------------------------------------+-------------------------------------
 Example:

 {{{
 from django.db import models

 class Foo(models.Model):
     amount = models.DecimalField(decimal_places=2, max_digits=12)

 from myapp.models import Foo
 f = Foo(amount='1.125')
 f.save()
 f.refresh_from_db()

 # the issue is here
 f.amount  # returns Decimal('1.12') in 3.1 and Decimal('1.13') in 3.2
 }}}

 Executed query for 3.2:
 {{{
 INSERT INTO "myapp_foo" ("amount") VALUES (1.125) RETURNING
 "myapp_foo"."id"
 }}}

 Executed query for 3.1:
 {{{
 INSERT INTO "myapp_foo" ("amount") VALUES ('1.12') RETURNING
 "myapp_foo"."id"
 }}}


 Issue was reproduced only when using postgres database.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/33232>
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/050.b9cf3230e1c78ca6495b82da8caf7ff4%40djangoproject.com.

Reply via email to