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

   # Description
   
   [CAMEL-25508](https://issues.apache.org/jira/browse/CAMEL-25508)
   
   `MyBatisProducer` ran `Insert`, `Update` and `Delete` statements once per 
element of `ObjectHelper.createIterator(body)`, with only a `Map` passed as-is 
(CAMEL-18321). `createIterator` also splits a `String` at every comma and 
iterates a primitive array, so a String parameter with a comma ran the 
statement once per part: inserting `"Doe, Jr."` inserted `"Doe"` and `" Jr."`, 
an update kept `" Jr."`, and deleting by `"Ibsen, Strachan"` deleted the rows 
of `"Ibsen"` and of `" Strachan"`. A `byte[]` ran the statement once per byte.
   
   This change passes a `Map`, a `String` (also a blank one, which did not run 
the statement before) and a primitive array as one parameter. Collections, 
iterators, streams and object arrays still run the statement once per element. 
The iteration dates from the first version of the component ("lets handle 
arrays or collections of objects"); the String splitting was never documented 
or tested, but a route could rely on it (for example a body `"1,2,3"` to delete 
three ids), so the 4.23 upgrade guide note is marked as a breaking change and 
says to send a `List` instead.
   
   Tests:
   - New `MyBatisStringParameterTest` (three String-parameter statements added 
to the test `Account.xml`): insert, update and delete with a comma, and insert 
of a blank String.
   - Without the change: all four fail, e.g. `There should be 1 row ==> 
expected: <1> but was: <0>` for the delete.
   - With the change: camel-mybatis 44 tests, 0 failures.
   
   Found with a Lean 4 model of the three statement types and the comma 
splitting: "a value that is not a collection reaches the statement as one 
parameter" fails for `"Doe, Jr."` and is proved to fail for every String with 
an inner comma; the fix is proved to satisfy it and to equal the current 
behaviour for every body that is not a String or a primitive array. I then 
reproduced it with the component.
   
   # Target
   
   - [x] I checked that the commit is targeting the correct branch (Camel 4 
uses the `main` branch)
   
   # Tracking
   - [x] If this is a large change, bug fix, or code improvement, I checked 
there is a [JIRA issue](https://issues.apache.org/jira/browse/CAMEL) filed for 
the change (usually before you start working on it).
   
   # Apache Camel coding standards and style
   
   - [x] I checked that each commit in the pull request has a meaningful 
subject line and body.
   - [ ] I have run `mvn clean install -DskipTests` locally from root folder 
and I have committed all auto-generated changes.
     (I built and tested camel-mybatis, including the formatter and import-sort 
plugins. I did not run the full root build.)
   
   # AI-assisted contributions
   
   - [x] If this PR includes AI-generated code, commits have proper 
co-authorship attribution (e.g., `Co-authored-by` trailers) and the PR 
description identifies the AI tool used.
     This PR was prepared with Claude Code (Claude Opus 5.5). The commit 
carries a `Co-Authored-By` trailer.
   
   _Claude Code on behalf of allthingssecurity_
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   


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