sqlalchemy-pydantic-orm icon indicating copy to clipboard operation
sqlalchemy-pydantic-orm copied to clipboard

Nested element can be updated

Open pmithrandir opened this issue 2 years ago • 1 comments

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

pmithrandir avatar Jan 03 '23 14:01 pmithrandir

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.

Wouterkoorn avatar Feb 28 '23 17:02 Wouterkoorn