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: Unique-fy ordering & projection created by IncludeComp… #10061

Merged
merged 2 commits into from
Oct 12, 2017

Conversation

smitpatel
Copy link
Contributor

…iler with existing ordering

Resolves #10045

The issue: When you have reference.collection include and orderby reference.property, the ordering is expanded by navigation rewrite and it is null-compensated. Whereas the ordering collection include adds missed null-compensation hence they were not matching property causing multiple orderings/projection in QueryModel, which would map to same SqlFragment causing projection count mismatch.
The fix is to unique-fy ordering by including null-compensation. Due to new pattern generated by Include, downstream code needs to understand & match more patterns.

I will add quirks once approved.

@smitpatel smitpatel changed the base branch from dev to rel/2.0.1 October 12, 2017 20:19
@smitpatel smitpatel requested review from anpete, maumar and ajcvickers and removed request for anpete October 12, 2017 20:19
@smitpatel smitpatel closed this Oct 12, 2017
@smitpatel smitpatel reopened this Oct 12, 2017
{
if (methodCallExpression.IsEFProperty())
{
var propertyName = (string)(methodCallExpression.Arguments[1] as ConstantExpression)?.Value;
Copy link
Contributor

Choose a reason for hiding this comment

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

Possible null ref?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

EFProperty method call so no null ref.

Copy link
Contributor

Choose a reason for hiding this comment

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

Change cast

@@ -197,19 +197,40 @@ var orderByClause
{
var propertyExpression = querySourceReferenceExpression.CreateEFPropertyExpression(property);

var orderingExpression = Expression.Convert(
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need to do this if FK is required?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We need to determine if the querySourceReferenceExpression here is nullable or not. Do we have a way to identify that?

}
}
}

private static bool MatchEfPropertyToMemberExpression(MemberExpression memberExpression, MethodCallExpression methodCallExpression)
Copy link
Contributor

Choose a reason for hiding this comment

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

We have similar code in LiftOrderBy

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yup, we do. I tried to make changes minimal in patch.

…iler with existing ordering

Resolves #10045

The issue: When you have reference.collection include and orderby reference.property, the ordering is expanded by navigation rewrite and it is null-compensated. Whereas the ordering collection include adds missed null-compensation hence they were not matching property causing multiple orderings/projection in QueryModel, which would map to same SqlFragment causing projection count mismatch.
The fix is to unique-fy ordering by including null-compensation. Due to new pattern generated by Include, downstream code needs to understand & match more patterns.
@smitpatel smitpatel merged commit 81d6c37 into rel/2.0.1 Oct 12, 2017
@joshmouch
Copy link

Sorry for the noob question, but when would this patch be available on NuGet?

@smitpatel smitpatel deleted the orderbyissue branch October 18, 2017 01:16
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.

4 participants