#29881: Decimal data type mapping triggers bug in MySQL
-------------------------------------+-------------------------------------
Reporter: parander | Owner: nobody
Type: Bug | Status: new
Component: Database | Version: 2.1
layer (models, ORM) | Keywords: mysql, decimal,
Severity: Normal | numeric
Triage Stage: | Has patch: 1
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 1
UI/UX: 0 |
-------------------------------------+-------------------------------------
Casting to DecimalField triggers a bug in MySQL due to DecimalField being
mapped to numeric.
Example:
Model.objects.annotate(bug=Cast('somefield', DecimalField(10,2)))
Will generate an error from MySQL, the issue is that MySQL has an issue
where it's not possible to cast to numeric as reported here:
https://bugs.mysql.com/bug.php?id=84558
With Django this happens due to the data type mapping defined in
data_types (db/backends/mysql/base.py:111 to be exact):
{{{
'DecimalField': 'numeric(%(max_digits)s, %(decimal_places)s)',
}}}
I propose that this line is changed to:
{{{
'DecimalField': 'decimal(%(max_digits)s, %(decimal_places)s)',
}}}
as this seems to be a simple work around for the underlying issue.
--
Ticket URL: <https://code.djangoproject.com/ticket/29881>
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 post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/051.6647d1af5def847463bee5f3e1b6c3ac%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.