Opened 4 weeks ago
Last modified 4 weeks ago
#36574 closed Bug
Regression: DecimalField values are no longer quantized before written to the DB — at Initial Version
Reported by: | Aaron Mader | Owned by: | |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | 5.2 |
Severity: | Normal | Keywords: | decimal_places |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Steps to reproduce:
- Create a new project using the mysql backend
- Create this model:
class Apple(models.Model): weight = models.DecimalField(max_digits=4, decimal_places=1)
- Create an instance of this record with input outside of the quantization limits
from decimal import Decimal Apple.objects.create( weight = Decimal("1.01"), )
- Attempt to fetch the record by the (expected) adjusted value
from decimal import Decimal Apple.objects.filter( weight = Decimal("1.0"), )
Specifically, this change in behaviour was introduced in django 5.2.0, with prior versions of django quantizing the input value (1.01
) to an acceptable value (1.0
) before writing the value to the database.
I believe that change was introduced in pull request: https://github.com/django/django/pull/18895
Note:
See TracTickets
for help on using tickets.