#28816: Silent data loss when decreasing the max_length of a CharField
-------------------------------------+-------------------------------------
Reporter: Gavin | Owner: nobody
Wahl |
Type: Bug | Status: new
Component: Database | Version: 1.11
layer (models, ORM) |
Severity: Normal | Keywords:
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
I have a CharField that I want to decrease the max_length on. I change the
value and generate a migration, then run it on my database.
Desired:
I should get an error from postgres if existing data doesn't fit in the
new length:
ERROR: value too long for type character varying(5)
Observed:
Any existing data longer than the new_max length is truncated and lost.
This behavior was introducted in #25002, which unconditionally added a
cast to the new type. This changes the default behavior of postgres (which
is to never lose data), to implicitly truncate. Django should not lose
data by default.
--
Ticket URL: <https://code.djangoproject.com/ticket/28816>
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/052.efaa621ea4c73984e3cea31cffc214f8%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.