-
Notifications
You must be signed in to change notification settings - Fork 350
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?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ | |
//--------------------------------------------------------------------- | ||
|
||
using System.Collections.Generic; | ||
using System.Linq; | ||
using Microsoft.OData.Edm; | ||
|
||
namespace Microsoft.OData.UriParser | ||
|
@@ -36,6 +37,7 @@ public ODataPathInfo(ODataPath odataPath) | |
|
||
this.targetNavigationSource = lastSegment.TargetEdmNavigationSource; | ||
this.targetEdmType = lastSegment.EdmType; | ||
|
||
if (this.targetEdmType != null) | ||
{ | ||
IEdmCollectionType collectionType = this.targetEdmType as IEdmCollectionType; | ||
|
@@ -44,6 +46,19 @@ public ODataPathInfo(ODataPath odataPath) | |
this.targetEdmType = collectionType.ElementType.Definition; | ||
} | ||
} | ||
|
||
// 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) | ||
{ | ||
IEdmOperation operation = operationSegment.Operations.FirstOrDefault(); | ||
|
||
if (operation.IsBound & previous != null) | ||
Comment on lines
+55
to
+57
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
{ | ||
this.targetNavigationSource = previous.TargetEdmNavigationSource; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could There was a problem hiding this comment. Choose a reason for hiding this commentThe 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? There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @KenitoInc Without even getting into whether this is the right fix, |
||
} | ||
} | ||
} | ||
|
||
this.segments = odataPath; | ||
|
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...