Nested element can be updated #4
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
My code intend to correct few issues.
1
Nested elements might not be created / updated when the parent element is.
My code allow a mix of update and create element in the entire hierarchy.
A new element can contain an existing one for example.
2
In some cases, the self.fields_set variable doesn't contain some element. In my case, it was a list issued by a foreign key.
It might be a bug in pydantic, but in order to prevent that issue, I pushed a change to use fields instead.
3 The code is now also compatible with Optional elements without default value.
It was not working fully in the case a List element was optional, without a default value.(it was trying to insert None, leading to an exception
please tell me if my code needs improvements.
Regards,
Pierre