#32435: Bug in JsonField creation with null=False
-----------------------------------------+---------------------------
Reporter: rcampos87 | Owner: nobody
Type: Bug | Status: new
Component: Uncategorized | Version: 3.1
Severity: Normal | Keywords: jsonfield
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-----------------------------------------+---------------------------
I recently updated my project's Django to version 3.1.5 and removed its
jsonfield dependency to use the new JSONField released with Django 3.1.
However i'm experiencing quite a strange bug.
I was experimenting creating a new JSONField with different options and
here is what i found:
Suppose I have a migration like this
{{{
migrations.AlterField(
model_name='awsuserschedule',
name='selected_ids',
field=common.fields.JSONField(encoder=common.encoders.JSONEncoder,
null=True),
),
migrations.AlterField(
model_name='awsuserschedule',
name='tags',
field=common.fields.JSONField(default=list,
encoder=common.encoders.JSONEncoder),
),
migrations.AlterField(
model_name='userscheduleslog',
name='instance_ids',
field=common.fields.JSONField(default=list,
encoder=common.encoders.JSONEncoder, null=False),
),
}}}
When i run sqlmigrate to analyze this migration i get:
{{{
-- Alter field selected_ids on awsuserschedule
--
ALTER TABLE `aws_user_schedules` MODIFY `selected_ids` json NULL;
--
-- Alter field tags on awsuserschedule
--
--
-- Alter field instance_ids on userscheduleslog
--
}}}
So you see that when '''null is not passed''', or '''null=False''', there
is no sql query created at all. I'm using MySQL 5.7.22. Am i doing
something wrong?
Thanks
--
Ticket URL: <https://code.djangoproject.com/ticket/32435>
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 view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/052.47ce047152755ff96362107558058003%40djangoproject.com.