{{{
subject2 = models.CharField(max_length=512, blank=True, null=True,
default="Some text")
body2 = models.TextField(blank=True, null=True, default="Some text")
}}}
After migration in MySQL 8.0.19, for existing data, new CharField column
populate that default "Some text" value. However, TextField is just null.
This inconsistent behaviour is very confusing.
--
Ticket URL: <https://code.djangoproject.com/ticket/32925>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
Old description:
> When adding 2 new fields, one is CharField and another is TextField, they
> both nullable with default value:
>
> {{{
> subject2 = models.CharField(max_length=512, blank=True, null=True,
> default="Some text")
> body2 = models.TextField(blank=True, null=True, default="Some text")
> }}}
>
> After migration in MySQL 8.0.19, for existing data, new CharField
> column populate that default "Some text" value. However, TextField is
> just null. This inconsistent behaviour is very confusing.
New description:
When adding 2 new fields, one is CharField and another is TextField, they
both nullable with default value:
{{{
subject2 = models.CharField(max_length=512, blank=True, null=True,
default="Some text")
body2 = models.TextField(blank=True, null=True, default="Some text")
}}}
After migration in MySQL 8.0.19, for existing data, new CharField column
populate that default "Some text" value. However, TextField is just null.
This inconsistent behaviour is very confusing.
Django version is 3.2.5.
--
--
Ticket URL: <https://code.djangoproject.com/ticket/32925#comment:1>
* status: new => closed
* resolution: => invalid
Comment:
Thanks for the report, unfortunately there is not much we can do. MySQL
8.0.13+ supports BLOB/TEXT defaults (see #30712) but it's really limited
(see #32832).
--
Ticket URL: <https://code.djangoproject.com/ticket/32925#comment:2>
Comment (by Edgenius):
I doubt if this need to rely on database. It can programatically update
this default value to the existing columns when runs migrate. At
model.save(), it can save this default value to database. Yes, I
understand this need some tweak on migration code, but it most like an
inconsistent from django, rather than database limitation.
--
Ticket URL: <https://code.djangoproject.com/ticket/32925#comment:3>