gnodet opened a new pull request, #27535:
URL: https://github.com/apache/camel/pull/27535

   ## Summary
   
   Fixes a batch of confirmed conversion bugs spanning all three layers of the 
`camel-dataweave` converter.
   
   Closes CAMEL-25324.
   
   ## Bugs fixed
   
   ### Lexer (`DataWeaveLexer`)
   
   | Token | Problem | Fix |
   |-------|---------|-----|
   | `@` | Silently dropped — `payload.Order.@id` became `body.Order.id` | 
Added `AT` token type |
   | `?` | Silently dropped — `payload.a?` became `body.a` | Added `QUESTION` 
token type |
   | `$$` | Split as two `$` tokens — reduce accumulator shorthand broken | 
Added `DOLLAR_DOLLAR` token type, lexed greedily |
   
   ### Parser (`DataWeaveParser`)
   
   | Construct | Problem | Fix |
   |-----------|---------|-----|
   | `var rate = 0.08` above `---` | Silently dropped — "Unknown variable rate" 
at runtime | `parseHeader()` now collects `var`/`fun` declarations and wraps 
the body in a `Block` |
   | `fun f(a: Number): Number = ...` | `: Number` type annotations mis-parsed 
as param names | `parseFunDecl()`, `parseLambda()`, and header `fun` parsing 
now skip `: Type` annotations |
   | `($$ + $.price)` passed to `reduce` | `parseLambda()` consumed `$$` and 
`+` as param names | `parseLambda()` now throws (triggering fallback) if a 
non-`IDENTIFIER` is seen as param |
   | `payload.Order.@id` | `.@` sequence not recognized | `parsePostfixOps()` 
handles `.` followed by `AT` as `AttributeAccess` |
   | `payload.a?` | `?` not recognized | `parsePostfixOps()` handles `QUESTION` 
as `ExistenceCheck` |
   | `$$` in expression | No AST node | `parsePrimary()` and 
`parseLambdaOrShorthand()` emit `DoubleDollar` AST node |
   
   ### Converter (`DataWeaveConverter`)
   
   | Construct | Problem | Fix |
   |-----------|---------|-----|
   | `"say \"hi\""` | Double-escape: `\"` became `\\\"` in output | Removed 
erroneous `.replace('"', '\"')` — lexer already stores verbatim |
   | `"Hello $(name)"` | String interpolation `$(…)` passed through as literal 
text | `emitStringLit()` replaces `$(` with `%(` (DataSonnet interpolation 
syntax) |
   | `payload.Order.Items.*Item` | Emitted `std.map(function(x) x.Item, …)` 
which fails for single XML children | Now emits `c.multiValue(collection, 
"field")` which handles one-or-many |
   | `payload.Order.@id` | New `AttributeAccess` node lacked emitter | Added 
`emitAttributeAccess()` → `body.Order["@id"]` |
   | `payload.a?` | New `ExistenceCheck` node lacked emitter | Added 
`emitExistenceCheck()` → `c.exists(body.a)` |
   | `$$` | New `DoubleDollar` node lacked emitter | Emitted as `acc` 
(accumulator convention) |
   | `groupBy ((i) -> i.qty)` | Numeric key caused "expected String, got 
number" in DataSonnet | `emitGroupBy()` now wraps key expression in 
`std.toString()` |
   
   ## Tests
   
   - `DataWeaveLexerTest`: updated 1 test (`@` is now a recognized `AT` token), 
added 4 new tests for `$$`, `@`, `?` tokenisation
   - `DataWeaveConverterTest`: updated 1 test (`testMultiValueSelector` for new 
`c.multiValue` output), added 10 new tests covering every fix
   - All 104 tests pass
   
   ## Deferred
   
   `match`, `mapObject`, `pluck`, `..` (descendant), and `[?()]` (key-filter) 
are deferred to follow-up per the issue description.


-- 
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]

Reply via email to