Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[2.0.1] Query: Fix for #9892 GroupJoin to parent with no child throws… #9982

Merged
merged 1 commit into from
Oct 5, 2017

Conversation

smitpatel
Copy link
Contributor

… invalid operation exception

Issue: When we are trying to lift GroupJoin queries without DefaultIfEmpty, we generate LEFT JOIN which means the inner can be null too. But we still have inner key selector doing property access on inner which could throw null ref. If the inner is using EntityShaper then shaper & all access becomes null safe, but in other cases it fails.
Solution: Since inner is projecting out a non-entity, we would always have TypedProjectionShaper, which does not have null safe mechanism. Hence For such queries we need to block lifting into lift join

Resolves #9892

… invalid operation exception

Issue: When we are trying to lift GroupJoin queries without DefaultIfEmpty, we generate LEFT JOIN which means the inner can be null too. But we still have inner key selector doing property access on inner which could throw null ref. If the inner is using EntityShaper then shaper & all access becomes null safe, but in other cases it fails.
Solution: Since inner is projecting out a non-entity, we would always have TypedProjectionShaper, which does not have null safe mechanism. Hence For such queries we need to block lifting into lift join

Resolves #9892
QueryModel queryModel,
int index)
{
var additionalFromClause
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be DRY with method below but for the patch I kept it separate.

@smitpatel smitpatel requested review from anpete and maumar October 5, 2017 20:08
@@ -1516,6 +1516,19 @@ var innerShapedQuery
return false;
}

if (!(AppContext.TryGetSwitch("Microsoft.EntityFrameworkCore.Issue9892", out var enabled) && enabled))
{
if (!IsFlattenableGroupJoinDefaultIfEmpty(groupJoinClause, queryModel, index))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Combine conditions

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kept it separate intentionally.
In past @anpete raised point not to combine conditions of quirks with code so that it becomes easy to understand exact condition.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fair enough

@smitpatel smitpatel merged commit 3d6caba into rel/2.0.1 Oct 5, 2017
@smitpatel smitpatel deleted the fix9892 branch October 5, 2017 23:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants