You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
More strict .update validation for non-nullable fields #3348
As said in the comment below,MyModel.objects.all().update(id=None) should raise an error.
At runtime, it would be an IntegrityError: (1048, "Column 'id' cannot be null")
It affects:
Field(primary_key=True)
Field(null=False)
- case: autofield_can_be_set_to_nonemain: | from myapp.models import MyModel, MyModelExplicitPK m = MyModel() m.id = 3 m.id = None m2 = MyModel(id=None) MyModel.objects.create(id=None) MyModel.objects.all().update(id=None) # Should give an error since there's a not-null constraint def foo(a: int) -> bool: return True m2 = MyModel() foo(m2.id) # At runtime, this would be an error, unless m.save() was called to populate the `id` field. # but the plugin cannot catch this. foo(m.id) exp = MyModelExplicitPK() exp.id = 3 exp.id = Noneinstalled_apps:
- myappfiles:
- path: myapp/__init__.py
- path: myapp/models.pycontent: | from django.db import models class MyModel(models.Model): pass class MyModelExplicitPK(models.Model): id = models.AutoField(primary_key=True)
changed the title [-]More strict `.update` validation for nun nullable fields[/-][+]More strict `.update` validation for non-nullable fields[/+]on May 1, 2026
Activity
[-]More strict `.update` validation for nun nullable fields[/-][+]More strict `.update` validation for non-nullable fields[/+]