-
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
Stop generating includes in nav expansion for primitive collection properties #34047
Conversation
@@ -236,8 +236,7 @@ protected override Expression VisitExtension(Expression extensionExpression) | |||
return QueryCompilationContext.NotTranslatedExpression; | |||
} | |||
|
|||
if (!(includeExpression.Navigation is INavigation includableNavigation | |||
&& includableNavigation.IsEmbedded())) | |||
if (includeExpression.Navigation is not INavigation includableNavigation || !includableNavigation.IsEmbedded()) |
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.
Cleanup only
@@ -564,6 +564,7 @@ protected override Expression VisitExtension(Expression extensionExpression) | |||
|
|||
case MaterializeCollectionNavigationExpression: | |||
case IncludeExpression: | |||
case PrimitiveCollectionReference: |
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.
This is the fix
|
||
public override async Task Array_of_byte() | ||
{ | ||
// TODO |
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.
This PR introduces the non-shared primitive collection tests for Cosmos - there are 3 failures. I've made a note and will investigate.
@@ -564,6 +564,7 @@ protected override Expression VisitExtension(Expression extensionExpression) | |||
|
|||
case MaterializeCollectionNavigationExpression: | |||
case IncludeExpression: | |||
case PrimitiveCollectionReference: | |||
return extensionExpression; |
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.
👍
The original implementation of primitive collections in 8.0 contained a bug, where nav expansion would generate IncludeExpressions for owned entity types of X when a primitive collection was accessed on X. So e.g.
context.Blogs.Select(b => b.Ints)
would get rewritten tocontext.Blogs.Select(b => [IncludeExpression].Ints)
. Nav expansion does not do this rewriting for regular property accesses, and so shouldn't do it for primitive collection properties either.This incorrect IncludeExpression was the root cause of #34008 in Cosmos. In relational, owned entities are handled in a special way during translation (ExpandSharedTypeEntities), and this IncludeExpression did not interfere - but it's still incorrect.
Fixes #34008
/cc @maumar