-
Notifications
You must be signed in to change notification settings - Fork 349
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 Filter and Orderby in Expand applied on bound functions #2701
base: release-7.x
Are you sure you want to change the base?
Fix Filter and Orderby in Expand applied on bound functions #2701
Conversation
This PR has Quantification details
Why proper sizing of changes matters
Optimal pull request sizes drive a better predictable PR flow as they strike a
What can I do to optimize my changes
How to interpret the change counts in git diff output
Was this comment helpful? 👍 :ok_hand: :thumbsdown: (Email) |
|
||
if (operation.IsBound & previous != null) | ||
{ | ||
this.targetNavigationSource = previous.TargetEdmNavigationSource; |
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.
Could previous.TargetEdmNavigationSource
also be null, or that isn't an issue?
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.
What if the return type of the of the operation does not match the navigation source of the previous segment?
For example, what if we have something like Customers/NS.GetTopOrders()?$expand=Products($filter=Category eq 'Electronics')
where GetTopOrders
returns a collection of Order
entities from an Orders
entity set, which is different from Customers
entity set?
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.
I don't think we should delegate the targetNS to the NS of preview segment.
we'd figure out why ODL needs the targetNS? If the last operation doesn't have the targetNS, can we use the return type of the operation to do something? I do think we use the TargetNS to calculate the context URL, if we don't have the NS, we should use the type to generate the Context URL. @mikepizzo
IEdmOperation operation = operationSegment.Operations.FirstOrDefault(); | ||
|
||
if (operation.IsBound & previous != null) |
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.
FirstOrDefault()
would return null
if no element if found and therefore the Ln57
would through an error. If we are certain about getting an element, then FirstOrDefault()
would be unnecessary, using First()
would suffice. Better still we can use Single()
to retrieve the element if we are always expecting a single element.
|
||
if (operation.IsBound & previous != null) | ||
{ | ||
this.targetNavigationSource = previous.TargetEdmNavigationSource; |
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.
I don't think we should delegate the targetNS to the NS of preview segment.
we'd figure out why ODL needs the targetNS? If the last operation doesn't have the targetNS, can we use the return type of the operation to do something? I do think we use the TargetNS to calculate the context URL, if we don't have the NS, we should use the type to generate the Context URL. @mikepizzo
|
||
if (operation.IsBound & previous != null) | ||
{ | ||
this.targetNavigationSource = previous.TargetEdmNavigationSource; |
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.
@KenitoInc Without even getting into whether this is the right fix, previous.TargetNavigationSource
is null if previous
is a KeySegment
- e.g. for the case where the function is bound to an entity. On the other hand, (previous as KeySegment).NavigationSource
is not null.
// If the last segment is an OperationSegment for a bound operation and the targetNavigationSource is null, | ||
// We use the targetNavigationSource for the previous segment. | ||
// e.g People/My.Function.GetPeopleWithDogs() | ||
if (this.targetNavigationSource == null && lastSegment is OperationSegment operationSegment) |
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 where you'd check if previous
is null to avoid doing a lot of work for nothing...
I think there was a clear reason why by design, applying It’s from the |
Issues
This pull request fixes #1162 .
Description
If we don't have an entity set path, the
OperationSegment
created doesn't have aTargetEdmNavigationSource
. This cause theTargetNavigationSource
inODataPathInfo
to benull
.For bound operation, this PR sets the
TargetNavigationSource
using theTargetEdmNavigationSource
of the previous segment. e.gTake the request
Get ~/People/My.Function.GetPeopleWithDogs($filter=ID eq 1)
If
GetPeopleWithDogs
operation segment doesn't have aTargetEdmNavigationSource
, we use theTargetEdmNavigationSource
from thePeople
entityset segmentChecklist (Uncheck if it is not completed)
Additional work necessary
If documentation update is needed, please add "Docs Needed" label to the issue and provide details about the required document change in the issue.