[release/7.0] Fix to #30028 - Added nullable property to Json mapped model resulting in errors instead of mapping non existing json property to null #30333
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.
Ported from #30101
Fixes #30028
Description
Projecting or accessing into JSON object that has an optional subdocument that is missing (rather than being null) throws during query.
Customer impact
Customers are unable to query JSON objects when they are missing part of the document (which should be allowed when mapped using optional navigation). There is no good workaround, customers need to edit JSON and add the missing element(s). Also, we already patched similar issue, when the "leaf" property was missing rather than navigation - see #29219
How found
Multiple customer reports on 7.0.
Regression
No. JSON support has been introduced in 7.0.
Testing
Added regression tests.
Risk
Low-Mid; Fix is relatively small and involves hand-crafting expression call to TryGetValue() rather than GetValue() that we used before. Additional risk comes from the fact that the change is in common code path. It gets used every time JSON is mapped to entities that are nested (e.g. Customer entity having Details entity mapped to JSON, and Details entity itself has a sub-entity Address mapped to the same JSON). Added quirk to revert to old behavior if necessary.