-
Notifications
You must be signed in to change notification settings - Fork 352
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
Expand fully qualified type #2160
Expand fully qualified type #2160
Conversation
src/Microsoft.OData.Core/UriParser/Binders/SelectExpandBinder.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.OData.Core/UriParser/Binders/SelectExpandBinder.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.OData.Core/UriParser/Binders/SelectExpandBinder.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.OData.Core/UriParser/Binders/SelectExpandBinder.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.OData.Core/UriParser/SemanticAst/ODataExpandPath.cs
Outdated
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.
LGTM
if (firstNonTypeToken.NextToken != null && firstNonTypeToken.NextToken.IsNamespaceOrContainerQualified()) | ||
{ | ||
hasDerivedTypeSegment = true; | ||
derivedType = UriEdmHelpers.FindTypeFromModel(this.Model, firstNonTypeToken.NextToken.Identifier, this.configuration.Resolver); |
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 you need any special handling for FindTypeFromModel not finding the type? In that case, I believe derivedType would return null, and it looks like CheckRelatedTo may throw a null ref exception as IsRelatedTo will return false, but the exception that we try to generate on line 57 of EdmUriHelpers will try to call FullTypeName() on the null value.
Minimally, we should fix EdmUriHelpers.CheckRelatedTo to handle the null childType and add tests for adding a cast segment with a type that is not found.
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.
When FindTypeFromModel
doesn't find the type it returns a null. I have added code to throw an exception when the derivedType
is null
.
Regarding EdmUriHelpers.CheckRelatedTo
, I have handled the null childType
similar to how a null parentType
is handled.
@@ -1667,6 +1667,96 @@ public void ExpandWithNavigationPropCountWithSearchOptionWorks() | |||
Assert.NotNull(expandedCountSelectItem.SearchOption); | |||
} | |||
|
|||
// $expand=navProp/fully.qualified.type/$count |
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.
should also have tests for /$expand=navProp/fully.qualified.type/$ref #Closed
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.
Done
@@ -1667,6 +1667,96 @@ public void ExpandWithNavigationPropCountWithSearchOptionWorks() | |||
Assert.NotNull(expandedCountSelectItem.SearchOption); | |||
} | |||
|
|||
// $expand=navProp/fully.qualified.type/$count |
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.
Can we add tests for fully.qualified.type being an alias? #Closed
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.
@mikepizzo I am not sure what you mean. Kindly clarify.
cc @gathogojr
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.
From the spec, parameter aliases are only used for $filter
or $orderby
https://docs.oasis-open.org/odata/odata/v4.01/odata-v4.01-part2-url-conventions.html#sec_ParameterAliases
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.
Sorry; i meant using a (namespace alias)[http://docs.oasis-open.org/odata/odata-csdl-xml/v4.01/odata-csdl-xml-v4.01.html#sec_Alias] to qualify the type name, rather than the full namespace name.
For example:
...$expand=navProp/alias.type
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.
@mikepizzo I have added the tests
@@ -1667,6 +1667,96 @@ public void ExpandWithNavigationPropCountWithSearchOptionWorks() | |||
Assert.NotNull(expandedCountSelectItem.SearchOption); | |||
} | |||
|
|||
// $expand=navProp/fully.qualified.type/$count |
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.
Please add a (negative) test case for fully.qualified.undefinedType and verify meaningful exception (i.e., saying that the type fully.qualified.undefinedType was not found). #Closed
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.
Done
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.
🕐
@@ -846,7 +846,7 @@ PathParser_TypeCastOnlyAllowedInDerivedTypeConstraint=Type cast segment '{0}' on | |||
|
|||
ODataResourceSet_MustNotContainBothNextPageLinkAndDeltaLink=A resource set may contain a next page link, a delta link or neither, but must not contain both. | |||
|
|||
ODataExpandPath_OnlyLastSegmentMustBeNavigationProperty=The last segment, and only the last segment, must be a navigation property in $expand. | |||
ODataExpandPath_OnlyLastSegmentMustBeNavigationPropertyOrTypeSegment=The last segment, and only the last segment, must be a navigation property or type segment in $expand. |
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.
Does this imply that it's not allowed to have type segments before the last segment?
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.
Good catch.
We can have type segments before the last segments.
The error string should be
ODataExpandPath_LastSegmentMustBeNavigationPropertyOrTypeSegment
= The last segment must be a navigation property or type segment in $expand.
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) |
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.
Issues
This pull request fixes #1870 .
Description
Briefly describe the changes of this pull request.
Checklist (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.