Skip to content
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

CASE not working in $compute and $filter #2309

Open
savicarlone1977 opened this issue Feb 2, 2022 · 2 comments · May be fixed by #2356
Open

CASE not working in $compute and $filter #2309

savicarlone1977 opened this issue Feb 2, 2022 · 2 comments · May be fixed by #2356

Comments

@savicarlone1977
Copy link

CASE is not working at all in $compute and $filter clauses

Assemblies affected

OData .Net lib 8.0.7

Reproduce steps

Call OData V4 service built using NET 6 and try a $compute with CASE clause

Expected result

Tha additional field

Actual result

Exception in parser

@xuzhg
Copy link
Member

xuzhg commented Feb 8, 2022

@savicarlone1977 Thanks for reporting this. Unfortunately, 'case' is not supported yet on the ODL side.

Here's the information for the "case" function:

5.1.1.12 Conditional Functions
5.1.1.12.1 case
The case function has the following signature:

expression case(Edm.Boolean:expression, ..., Edm.Boolean:expression)

Each parameter is a pair of expressions separated by a colon (:), where the first expression – the condition – MUST be a Boolean expression, and the second expression – the result – may evaluate to any type.

The case function evaluates the condition in each pair, starting with the leftmost pair, and stops as soon as a condition evaluates to true. It then returns the value of the result of this pair. It returns null if none of the conditions in any pair evaluates to true. Clients can specify a last pair whose condition is true to get a non-null “default/else/otherwise” result.

Clients SHOULD ensure that the results in all pairs are compatible. If all results are of the same type, the type of the case expression is of that type. If all results are of numeric type, then the type of the case expression is a numeric type capable of representing any of these expressions according to standard type promotion rules.

Services MAY support case expressions containing parameters of incompatible types, in which case the case expression is treated as Edm.Untyped and its value has the type of the parameter expression selected by the case statement.

Example 97: compute signum(X)

$compute=case(X gt 0:1,X lt 0:-1,true:0) as SignumX

@gathogojr
Copy link
Contributor

@savicarlone1977 This is a feature gap and we have added the issue to our backlog. However, we do welcome contributions so if this is a feature you might have room to work on we'd very happy to review the pull request.

@xuzhg xuzhg linked a pull request Mar 18, 2022 that will close this issue
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants