-
Notifications
You must be signed in to change notification settings - Fork 21
Open
Description
Say in version N of my project I have this model and code that assumes foo_instance.text_field is always going to be a string.
class FooModel(models.Model):
text_field = models.CharField(max_length=256)Then in version N+1 I then deprecate it
class FooModel(models.Model):
text_field = deprecate_field(models.CharField(max_length=256), "")Then when version N and N+1 are running simultaneously:
- version
N+1inserts a row, it will havetext_field=NULL - version
Nselects this row, and assumestext_fieldis going to be a string, when it is actuallyNone - Potentially raising a
TypeError/ValueError
I'm not sure how this could be addressed by the django-deprecate-fields library. Maybe this just needs to be detailed in the docs.
For us the solution is to first use a AddDefaultValue operation on the field to add a database-level default. This is so the rows inserted by N+1 get this default value instead of NULL, so version N can still handle them.
Metadata
Metadata
Assignees
Labels
No labels