Allow a DecimalField's max_digits and decimal_places to be changed.

Review Request #11309 — Created Nov. 29, 2020 and submitted — Latest diff uploaded

Information

Django Evolution
release-2.x

Reviewers

We didn't have any support for actually changing a DecimalField's
max_digits and decimal_places attributes, which meant that once such
a field was added to a model, it could never be changed.

This change implements the ability to change these attributes. It
requires a bit of a change to the column attribute mutation logic, since
unlike most attributes, max_digits and decimal_places really need to
be considered together when updating the column. That's because in most
databases, they're defined as part of the column type
(numeric(max_digits, decimal_places)). The approach implemented is a
bit specialized for DecimalField, but if we encounter more situations
like this in the future, we'll be able to build upon it.

Unit tests pass for all databases and all versions of Django.

Commits

Files

    Loading...