Re: [Django] #36030: Expressions that divide an integer field by a constant decimal.Decimal returns no inconsistent decimal places on PostgreSQL (was: Rendering decimal to SQL is incoherent and leads to bugs. It relays on str formating not type.)

4 views
Skip to first unread message

Django

unread,
Dec 20, 2024, 11:41:29 AM12/20/24
to django-...@googlegroups.com
#36030: Expressions that divide an integer field by a constant decimal.Decimal
returns no inconsistent decimal places on PostgreSQL
-------------------------------------+-------------------------------------
Reporter: Bartłomiej Nowak | Owner: (none)
Type: Bug | Status: new
Component: Database layer | Version: 5.1
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Sarah Boyce):

* stage: Unreviewed => Accepted
* summary:
Rendering decimal to SQL is incoherent and leads to bugs. It relays on
str formating not type.
=>
Expressions that divide an integer field by a constant decimal.Decimal
returns no inconsistent decimal places on PostgreSQL

Comment:

I was able to replicate. Note that when using `Decimal("3.0")` it returns
`Decimal("0.66666666666666666666")`
Same thing on SQLite, I consistently get `Decimal("0")`
I'm not sure what this _should_ do but I agree this is confusing and
requires more investigation

Thank you for the ticket
--
Ticket URL: <https://code.djangoproject.com/ticket/36030#comment:6>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
Reply all
Reply to author
Forward
0 new messages