loaddata failure if model has overridden save() method
|Reported by:||russellm||Owned by:||russellm|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
If a model overrides the save() method, and performs a query in that save(), loaddata may fail when objects of that type are loaded. dumpdata/loaddata don't preserve dependency order (they can't really, because there could easily be circular dependencies), so loaddata can't guarantee that the subject of the search will have been deserialized yet.
I suspect that the fix for this is to introduce a 'raw save' - a guaranteed use of the original Model.save(), rather than the model's overidden variant.
raw_save should proabably also avoid running pre-save methods on fields - these methods can mutate the data as part of the load (e.g., you can't correctly deserialize an auto_add_now field, as deserializing will update the field).
The errors reported by #4431 are a direct cause of this problem.
Change History (5)
comment:1 Changed 9 years ago by russellm
- Needs documentation unset
- Needs tests unset
- Patch needs improvement unset