#36030: Rendering decimal to SQL is incoherent and leads to bugs. It relays on
str
formating not type.
-------------------------------------+-------------------------------------
Reporter: Bartłomiej Nowak | Type: Bug
Status: new | Component: Database
| layer (models, ORM)
Version: 5.1 | Severity: Normal
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
When I am using Decimal at Python level, I expect to use numeric type on
database level. But it seems to depend on string formatting of decimal
itself instead of type of object.
**See examples:**
`Decimal(1000.0)` --> will render as `1000` at query and will be **INT**
on db level.
`Decimal(1000)` --> will render as `1000` at query and will be **INT** on
db level.
`Decimal("1000.0")` -> will render as `1000,0` at query and will be
**NUMERIC** on db level.
`models.Value(1000.0, output_field=DecimalField())` -> will render as
`1000` at query and will be **INT** on db level.
`models.Value(1000.0)` (no decimal provided as above) -> will render as
`1000,0` at query and will be **NUMERIC** on db level.
It leads to bugs, cuz at DB LVL, INT / INT is also INT (2/3 = 0), and I
doubt anyone who provides decimal there, excepts that behavior.
--
Ticket URL: <https://code.djangoproject.com/ticket/36030>
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/01070193e348c7ac-5453b016-60e4-4c52-b16d-45f184347754-000000%40eu-central-1.amazonses.com.