Enable Deserialization of Many-to-One Nested Objects that DNE in DB #69
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.
Proposition: Given 'One' object composed of nested fields, with each
nested field containing 'Many' objects, on deserialization instantiate
each nested object into an instance of the nested field's SQLAlchemy
Model if it does not already exist in the DB.
Current behavior is to fail ungracefully & non-verbosely if a nested
object DNE in DB. The "NoResultFound" exception is raised by
"Query.one()".
A sample problem-case is as follows:
i.) A POST request is sent to a server, and contains a JSON object which contains both parent, and children which do not yet exist on the DB.
ii.) This object is deserialized with a (required) session object, and because the 2 books (in the collection of 'books' above) do not yet exist in the DB, an exception gets thrown when they are retrieved.
Without the 'books', the author object can be deserialized even though it has not yet been created on the DB. The proposed feature would keep this consistent across many-to-one nested objects.