﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
32793	Problem with decimal field when upgrade version	Mohsen Tamiz	Mariusz Felisiak	"A simple example such as:

{{{
#!python
from django.db import models

class Foo(models.Model):
    amount = models.DecimalField(
        null=False,
        decimal_places=18,
        max_digits=44)


# A simple insertion example 
from api.models import Foo
from django.db.models import F
from decimal import Decimal

f = Foo.objects.create(amount=Decimal('0.5'))
f.amount = F('amount') - Decimal('0.4')
f.save(update_fields=['amount', ])
f.refresh_from_db()
print(f.amount)
}}}
This creates an unexpected result (0.099999999999999980) in new version, but in previous version it was ok. I checked the difference and I found that new version sends a decimal value in a quotation, but in the previous version it would send in number format. Below is the query for two different versions:
{{{
#!mysql
3.1
UPDATE `api_foo` SET `amount` = (`api_foo`.`amount` - 0.4) WHERE `api_foo`.`id` = 1

3.2
UPDATE `api_foo` SET `amount` = (`api_foo`.`amount` - '0.4') WHERE `api_foo`.`id` = 1
}}}

I am using mysql-8.0.19.
"	Bug	closed	Database layer (models, ORM)	3.2	Release blocker	fixed	decimal	Simon Charette	Accepted	1	0	0	0	0	0
