-
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
FunctionCallBinder promotes arguments without checking return type #2257
Conversation
- Removed check for ReturnType in FunctionCallBinder before promoting function arguments
- unwrapped ConvertQueryNode for FunctionCallQueryNodes parameters
- unwrapped ConvertQueryNode for FunctionCallQueryNodes parameters
I tried to blindly fix the tests as well as I could, I hope they are OK. |
@JBBianchi Thanks for your contribution. Please rebase your branch. |
@@ -723,7 +723,8 @@ public void NullValueInCanonicalFunction() | |||
var result = ParseFilter("day(null)", HardCodedTestModel.TestModel, HardCodedTestModel.GetPaintingType()); | |||
|
|||
var typeReference = result.Expression.ShouldBeSingleValueFunctionCallQueryNode("day") | |||
.Parameters.Single().ShouldBeConstantQueryNode<object>(null).TypeReference; | |||
.Parameters.Single().ShouldBeConvertQueryNode(EdmPrimitiveTypeKind.DateTimeOffset) |
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.
Not sure I understand how the change to FunctionCallBinder
class results into the change to this test being required
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 guess it's because day()
is a function and the test was checking the parameter nodes type of that function. As the arguments are now "promoted", there is an extra hop via a convert node in the middle as day
supposedly requires a Date
or DateTime
and null is considerated as Object
. At least, that's my understanding but I'm far from knowning the OData inner workings, it's just an extrapolation based on the very little I saw.
- Removed check for ReturnType in FunctionCallBinder before promoting function arguments
- unwrapped ConvertQueryNode for FunctionCallQueryNodes parameters
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) |
@ElizabethOkerio Did I do ok? I'm not so familiar with git tbh. |
It looks fine. |
@JBBianchi Thanks for your contribution |
Issues
This pull request fixes #2241
Related to
OData/WebApi#1180
OData/WebApi#2173
OData/AspNetCoreOData#325
Description
In the
FunctionCallBinder
, the function signature's return type was checked before processing the arguments nodes. There is no apparent reason for this check which leads to some arguments being mistyped.The check has been removed, allowing the arguments to be
promoted
as they should.Checklist (Uncheck if it is not completed)
Additional work necessary
Unfortunately, I'm not able to launch the tests. If anybody could double check this commit and maybe add some tests, it would be very much appreciated! ❤️