sqlalchemy-pydantic-orm
sqlalchemy-pydantic-orm copied to clipboard
Nested element can be updated
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
This is quite a large chunk for me to review because I have to rethink why I made certain decisions, like choosing fields_set
over fields
.
Splitting the merge request up would help a lot. So each point you mentioned in it's own MR; same for spelling corrections.
Thank you for your understanding.