#25417: No warning raised when an invalid default is specified for a field
-------------------------------------+-------------------------------------
Reporter: avorio | Owner: nobody
Type: Bug | Status: new
Component: Migrations | Version: 1.8
Severity: Normal | Resolution:
Keywords: decimal, | Triage Stage: Accepted
InvalidOperation, migrations |
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by charettes):
* cc: charettes (added)
* stage: Unreviewed => Accepted
Comment:
I also managed to reproduce against 1.8.4 with Python 3.4 and PostgreSQL.
The issue is the first migration having an invalid field, `20.00` can't be
stored with three digits.
The reason an exception was not raised during the initial migration
generation and executing is that the default value is not used at table
creation. It would have also raised an exception if the field has been
added instead of altered.
I suggest we fix this by adding a field check that makes sure the default
value of a field is valid. We should also make sure that `DecimalField`
validation takes `max_digits` and `decimal_places` into account.
In the meanwhile you can work around this issue by editing the migration
containing the invalid field (`max_digits=3, decimal_places=2,
default=20.00`) to have a valid default value e.g.
`decimal.Decimal('2.00')`.
--
Ticket URL: <https://code.djangoproject.com/ticket/25417#comment:8>
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/064.86c6fde8fafa9048a79e3b42e5657f2c%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.