-
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
Fix to #29513 - Json: improve projection deduplication for scenarios containing collection indexers #29808
Conversation
{ | ||
if (!_jsonCollectionNonConstantElementAccessMap.TryGetValue(index, out var collectionElementAccessParameter)) | ||
{ | ||
collectionElementAccessParameter = Expression.Parameter(typeof(int?)); |
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 could store these values as int, rather than int? - this way we only need to perform convert to int once (i.e. here). If the value we get for the array is null, things break anyway later.
...l/Query/RelationalShapedQueryCompilingExpressionVisitor.ShaperProcessingExpressionVisitor.cs
Outdated
Show resolved
Hide resolved
...l/Query/RelationalShapedQueryCompilingExpressionVisitor.ShaperProcessingExpressionVisitor.cs
Outdated
Show resolved
Hide resolved
...l/Query/RelationalShapedQueryCompilingExpressionVisitor.ShaperProcessingExpressionVisitor.cs
Outdated
Show resolved
Hide resolved
...l/Query/RelationalShapedQueryCompilingExpressionVisitor.ShaperProcessingExpressionVisitor.cs
Show resolved
Hide resolved
...l/Query/RelationalShapedQueryCompilingExpressionVisitor.ShaperProcessingExpressionVisitor.cs
Show resolved
Hide resolved
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.
Looks good, and I think I'm even half-understanding it :)
See especially the comments about how to represent stuff inside JsonProjectionInfo, plus various nits.
...l/Query/RelationalShapedQueryCompilingExpressionVisitor.ShaperProcessingExpressionVisitor.cs
Show resolved
Hide resolved
...l/Query/RelationalShapedQueryCompilingExpressionVisitor.ShaperProcessingExpressionVisitor.cs
Outdated
Show resolved
Hide resolved
...l/Query/RelationalShapedQueryCompilingExpressionVisitor.ShaperProcessingExpressionVisitor.cs
Show resolved
Hide resolved
...l/Query/RelationalShapedQueryCompilingExpressionVisitor.ShaperProcessingExpressionVisitor.cs
Outdated
Show resolved
Hide resolved
...l/Query/RelationalShapedQueryCompilingExpressionVisitor.ShaperProcessingExpressionVisitor.cs
Outdated
Show resolved
Hide resolved
a4c718e
to
6ffd3e1
Compare
/// doing so can result in application failures when updating to a new Entity Framework Core release. | ||
/// </remarks> | ||
public (int? ConstantArrayIndex, int? NonConstantArrayIndex)[] ArrayElementAccessInfo { get; } | ||
public List<(IProperty? KeyProperty, int? ConstantKeyValue, int? KeyProjectionIndex)> KeyAccessInfo { get; } |
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.
maybe different order? (Constant, KeyProperty, KeyProjectionIndex) or (KeyProperty, KeyProjectionIndex, Constant) ?
@roji new version up - JsonProjectionInfo refactoring in separate commit, all other feedback addressed in the initial one |
ping @roji |
…containing collection indexers Reworking shaper to properly track key values for JSON entities that are accessed via array element. Every array access needs to be recorded and incorporated into the key later. Constants can be stored directly by value, non-constants are added to projection, and we keep track of the projection index instead. - added JsonProjectionInfo in place of a value tuple to store shaping info needed for JSON, so that it's more readable, - reworked JsonShapingPreProcess to generate and cache key values as well as JsonElement. - moved dangling (i.e. not coming from include on the owner entity) JSON entity processing after Include processing, so that we guarantee to have all the entities in state manager by the time we get to processing the dangling JSON stuff. Fixes #29513
Reworking shaper to properly track key values for JSON entities that are accessed via array element. Every array access needs to be recorded and incorporated into the key later. Constants can be stored directly by value, non-constants are added to projection, and we keep track of the projection index instead.
Fixes #29513