davsclaus opened a new pull request, #26764:
URL: https://github.com/apache/camel/pull/26764
```
${a > 0 && b < 10 ? 'x' : 'y'}
```
was refused with *Logical operator && needs a predicate on the right hand
side*, and parentheses did not help either, so the ternary could only ever test
a single comparison. Any real condition had to be lifted out of the braces —
and outside the braces a `?` and a `:` are literal text, so the ternary could
not be written at all. The only way out was a choice EIP or a bean.
**Cause.** A ternary inside `${ }` does not go through the predicate
parser's phases at all: `SimpleFunctionStart.doCreateTernaryExpression` splits
the text at `?` and `:`, and `wrapFunctionsInCondition` turns `body > 0` into
`${body} > 0` before the condition is parsed as a predicate. That method found
the **first** comparison operator, wrapped its left side and returned the
remainder untouched, so `body > 0 && body < 10` became `${body} > 0 && body <
10` and the `&&` had a bare `body` on its right.
It now splits the condition on `&&` and `||` outside quotes and wraps each
comparison.
```
${body > 0 && body < 10 ? 'in' : 'out'} -> in
${body > 0 || body > 100 ? 'in' : 'out'} -> in
${body > 0 && body < 10 && body != 7 ? 'in' : 'out'} -> in
${body != null && body contains 'ell' ? 'yes' : 'no'} -> yes
```
Two things the corner cases pin down, both tested:
- a quoted operator is still text: `${body contains 'a && b' ? 'yes' :
'no'}` works as before
- Simple has no word forms, and still says so: `${body > 0 and body < 10 ?
... }` is refused with *use && for and* — my first attempt treated `and`/`or`
as operators, which was wrong
I first tried reordering the parser phases (logical before ternary). The 616
simple tests stayed green but the compound ternary still failed, because the
in-function path above never reaches those phases; that attempt is not in this
PR.
`SimpleOperatorTest` 62 green, `*Simple*Test` 617 green, full reactor build
green. Documented in the operators page.
Related to CAMEL-24921, which asks the larger question — whether a predicate
inside `${ }` should evaluate at all, not only as a ternary condition. This gap
stands on its own either way.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_01Bp3538HRBPMQkb5ta9xRaj
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]