OrderBy doesn't support all expression defined in OData-ABNF
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 505
- Forks
- 186
- PR merge metrics
- No merged PRs in 30d
Description
Motivation:
I'm using OData library to get access to dynamic properties of my entity. Look #304 issue for details. I would like to execute queries like https://endpoint.ua/odata/entity?$orderby=cast(metadata/myValue, Edm.Int32). Currently OrderBy nodes can process only SingleValueOpenPropertyAccessNode or SingleValuePropertyAccessNode. It means that query in my example is considered invalid. However OData construction rules defines more valid expressions for orderby operation. Here is a part of it
orderby = ( "$orderby" / "orderby" ) EQ orderbyItem *( COMMA orderbyItem )
orderbyItem = commonExpr [ RWS ( "asc" / "desc" ) ]
And commonExpr might be castExpr which is cast function call. Some providers might not be able to translate it, but databases supports queries like this (postgres has CAST (field AS type) expression and MsSQL has similar option). But there should be ability to properly process query in case it might be executed.
Change proposal
Allow to pass commonExpr in orderby query. Which requires modification of OrderByNode class (to support more child nodes in this query).
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
Start by inspecting the OrderByNode class and the orderby parsing and validation path. Compare the currently accepted SingleValueOpenPropertyAccessNode and SingleValuePropertyAccessNode cases with the cast expression described in the issue and review existing tests for orderby expressions. Done means valid commonExpr expressions such as cast(metadata/myValue, Edm.Int32) are accepted without breaking existing orderby behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- api, backend
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100