Support for case method call
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 505
- Forks
- 186
- PR merge metrics
- No merged PRs in 30d
Description
According to OData documentation (https://docs.oasis-open.org/odata/odata/v4.01/odata-v4.01-part2-url-conventions.html#sec_case) we should be able to use case method call. I tried this with Microsoft.AspNetCore.OData version 8.0.11.
Client called this URL
http://localhost:60600/odata/Search?$select=name&$compute=case(indexof(name, 'test') eq -1:10000,true:indexof(name, 'test')) as rank&$orderby=rank asc
it returns following error
{
"error": {
"code": "",
"message": "The query specified in the URI is not valid. ')' or ',' expected at position 32 in 'case(indexof(name, 'test') eq -1:10000,true:indexof(name, 'test')) as rank'.",
"details": [],
"innererror": {
"message": "')' or ',' expected at position 32 in 'case(indexof(name, 'test') eq -1:10000,true:indexof(name, 'test')) as rank'.",
"type": "Microsoft.OData.ODataException",
"stacktrace": " at Microsoft.OData.UriParser.FunctionCallParser.ParseArgumentListOrEntityKeyList(Action restoreAction)\r\n at Microsoft.OData.UriParser.FunctionCallParser.TryParseIdentifierAsFunction(QueryToken parent, QueryToken& result)\r\n at Microsoft.OData.UriParser.IdentifierTokenizer.ParseIdentifier(QueryToken parent)\r\n at Microsoft.OData.UriParser.UriQueryExpressionParser.ParsePrimary()\r\n at Microsoft.OData.UriParser.UriQueryExpressionParser.ParseInHas()\r\n at Microsoft.OData.UriParser.UriQueryExpressionParser.ParseUnary()\r\n at Microsoft.OData.UriParser.UriQueryExpressionParser.ParseMultiplicative()\r\n at Microsoft.OData.UriParser.UriQueryExpressionParser.ParseAdditive()\r\n at Microsoft.OData.UriParser.UriQueryExpressionParser.ParseComparison()\r\n at Microsoft.OData.UriParser.UriQueryExpressionParser.ParseLogicalAnd()\r\n at Microsoft.OData.UriParser.UriQueryExpressionParser.ParseLogicalOr()\r\n at Microsoft.OData.UriParser.UriQueryExpressionParser.ParseExpression()\r\n at Microsoft.OData.UriParser.UriQueryExpressionParser.ParseComputeExpression()\r\n at Microsoft.OData.UriParser.UriQueryExpressionParser.ParseCompute(String compute)\r\n at Microsoft.OData.UriParser.ODataQueryOptionParser.ParseComputeImplementation(String compute, ODataUriParserConfiguration configuration, ODataPathInfo odataPathInfo)\r\n at Microsoft.OData.UriParser.ODataQueryOptionParser.ParseCompute()\r\n at Microsoft.AspNetCore.OData.Query.Validator.ODataQueryValidator.Validate(ODataQueryOptions options, ODataValidationSettings validationSettings)\r\n at Microsoft.AspNetCore.OData.Query.EnableQueryAttribute.ValidateQuery(HttpRequest request, ODataQueryOptions queryOptions)\r\n at Microsoft.AspNetCore.OData.Query.EnableQueryAttribute.OnActionExecuting(ActionExecutingContext actionExecutingContext)"
}
}
}
seems like case is not supported
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the case expression from the issue in the $compute query and start with the ODataQueryOptionParser.ParseCompute entry point and the FunctionCallParser stack frames. Trace how the expression is parsed, then verify that the documented case syntax is accepted and the query can order by the computed rank.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100