odmantic
odmantic copied to clipboard
Embedded Model Exclude None Not Functioning
Bug
Using 'exclude_none' in .update function does not work for fields in embedded models
Current Behavior
Create 'model' with embedded model in field. Use 'exclude_none' in 'model.update(*, exclude_none=True). Field with non-null value becomes null in embedded model.
Expected behavior
Fields in embedded model should not change from a non-null value to a null if exclude_none is set to True.
Environment
- ODMantic version: odmantic==0.8.0
@art049 hey Arthur. I made a PR for this #355 . It uses a recursive function to avoid the patch object values overwriting the values we wish to keep, if they are None. This logic only happens if exclude_none is set to true. Let me know if there is any feedback, but the solution I wrote works for nested dictionaries and lists of nested dictionaries.