#36030: SQLite backend: division with Decimal("x.0") operand discards fractional
portion of result
-------------------------------------+-------------------------------------
Reporter: Bartłomiej Nowak | Owner: VIZZARD-X
Type: Bug | Status: assigned
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution:
Keywords: division | Triage Stage: Accepted
decimalfield sqlite |
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by VIZZARD-X):
I have updated the implementation to explicitly cast `Value(Decimal)`
literals to `REAL` on SQLite (instead of removing the cast entirely). This
aligns with the documentation stating that SQLite internally handles
Decimals as REAL types, ensuring that division operations preserve
fractional precision.
I also updated the regression test to verify that `CAST(... AS REAL)` is
present in the generated SQL.
- updated the pull request to include a functional regression test that
verifies the observable outcome (correct decimal precision during division
on SQLite), as suggested during review.
PR: https://github.com/django/django/pull/20309
--
Ticket URL: <https://code.djangoproject.com/ticket/36030#comment:45>
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/0107019bc70ac166-38a9f4c0-adbc-4245-a568-edbab6135208-000000%40eu-central-1.amazonses.com.