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

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

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.

Summary ID
Allow a DecimalField's max_digits and decimal_places to be changed.
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.
5faedd53b6c40b05c9b13831d44b50126c3230ff
david
  1. Ship It!
  2. 
      
chipx86
Review request changed
Status:
Completed
Change Summary:
Pushed to master (17fdade)