Assigning bad data to an m2m attribute should not clear existing data
|Reported by:||Carl Meyer||Owned by:||nobody|
|Component:||Database layer (models, ORM)||Version:||master|
|Has patch:||yes||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||yes|
If you assign something nonsensical to a many-to-many attribute on a model instance, you'll get a
TypeError; but not until after Django has cleared all the existing relationship data. Ideally Django would verify that you've passed in something reasonable before it clears the existing data.
(This issue was originally half of #14373).
Attached patch with test demonstrating the issue.
Change History (17)
comment:1 Changed 6 years ago by
|Patch needs improvement:||unset|
|Triage Stage:||Unreviewed → Accepted|
Changed 6 years ago by
comment:11 Changed 5 years ago by
|Patch needs improvement:||set|