[release/7.0] Fix for #30266 and #30565 - projecting json entity/reference as well as regular entity collection #30600
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.
Port of #30566
Port of #30568
Fixes #30266
Fixes #30565
Description
Projecting JSON entity or JSON collection combined with projecting of regular entity collection fails (with unhelpful message) during compile time. Workaround exists but it's not very discoverable and requires query rewrite (project entire entity and bring back the requested collection by applying include beforehand).
Customer impact
Queries with affected entities throw during compilation.
How found
Multiple customer reports on 7.0
Regression
No. JSON support is new functionality in 7.0.
Testing
Added regression tests for affected scenarios.
Risk
Low: While scenario is quite common, the fix is isolated to only affecting the scenario (i.e. when entity collection is projected along with json entity/collection). Moreover, fix is to apply the same logic that we use for non-JSON entity scenarios, so we have good degree of confidence that the logic is sound.
Those two issues are very closely related. Initially we thought that fix for #30565 would be significantly more risky/complex, so we split the bugs apart, but we were able to find a better fix that is only marginally more risky than #30266 and the resulting risk for combined issue is still low.
Added quirk to revert to old behavior if necessary.