-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Conversation
{ | ||
if (methodCallExpression.IsEFProperty()) | ||
{ | ||
var propertyName = (string)(methodCallExpression.Arguments[1] as ConstantExpression)?.Value; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Possible null ref?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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( |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
cb83d65
to
81d6c37
Compare
Sorry for the noob question, but when would this patch be available on NuGet? |
…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.