#32793: Problem with decimal field when upgrade version
-------------------------------------+-------------------------------------
Reporter: Mohsen Tamiz | Owner: Mariusz
| Felisiak
Type: Bug | Status: assigned
Component: Database layer | Version: 3.2
(models, ORM) |
Severity: Release blocker | Resolution:
Keywords: decimal | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Mariusz Felisiak):
Replying to [comment:8 Mariusz Felisiak]:
> I noticed that the same test but with `f.amount = F('amount') -
Decimal(0.4)` (no parentheses) crashes on MySQL:
> {{{
> File "/tests/django/django/db/backends/utils.py", line 238, in
format_number
> value = context.create_decimal(value)
> decimal.Rounded: [<class 'decimal.Rounded'>]
> }}}
I tried to add a test with `Decimal(0.4)` but currently it crashes on
SQLite and Oracle, IMO we can leave it as a separate issue.
{{{
def test_decimal_expression_(self):
n = Number.objects.create(integer=1, decimal_value=Decimal('0.5'))
n.decimal_value = F('decimal_value') - Decimal(0.4)
n.save()
n.refresh_from_db()
self.assertAlmostEqual(n.decimal_value, Decimal('0.1'), 16)
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/32793#comment:9>
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/063.376baca941f8a8aef4c1ccf3bf8614e2%40djangoproject.com.