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

   Fixes [CAMEL-26067](https://issues.apache.org/jira/browse/CAMEL-26067).
   
   ## What was wrong
   
   With `useHeadersAsParameters=true` and a query with only plain `?` 
placeholders (no `:?name`), 
`DefaultJdbcPrepareStatementStrategy.createPopulateIterator` bound the values 
of **all the message headers** by position (or of the `CamelJdbcParameters` map 
when it was set), until the statement had enough values. Which value went to 
which `?` depended on which headers the message had and in what order, 
including headers set by the consumer and Camel's own headers. That order also 
changed in 4.21 (CAMEL-23691: insertion order instead of alphabetical). The 
only test used a single header.
   
   ## What changed
   
   - Plain `?` placeholders now take their values only from the 
`CamelJdbcParameters` header: a `List` (any `Iterable`, or an array) in the 
order of the placeholders, or a `Map` whose values are taken in the order of 
its entries (as before when the header was set).
   - When the header is not set, the exchange fails with a 
`RuntimeExchangeException` that says to set the values as a List in 
`CamelJdbcParameters` or to use named parameters. A header of another type (for 
example a `String`) fails with a message naming its type. Before, such a header 
failed with `Number of parameters mismatch`.
   - Named parameters (`:?name`) are unchanged: `CamelJdbcParameters` (a Map) 
when set, else the message headers.
   - `spring-jdbc` uses the same strategy, so it gets the same behaviour. Its 
`@BodyTypes` text is updated like the jdbc one.
   
   ## Tests
   
   `JdbcParameterizedQueryTest`:
   - `testParameterizedQueryNoNames` now sets a `List` in `CamelJdbcParameters` 
next to other headers, and checks the other headers are not bound.
   - `testParameterizedQueryNoNamesMap`: a `LinkedHashMap` in 
`CamelJdbcParameters` is bound in entry order.
   - `testParameterizedQueryNoNamesNotFromHeaders`: plain headers only, the 
exchange fails with the new message.
   - `testParameterizedQueryNoNamesInvalidParameters`: a `String` header fails 
with the new message.
   
   Three of the four failed without the fix (the Map case already worked). 
camel-jdbc: 56 tests pass. camel-spring-jdbc: 2 tests pass.
   
   ## Docs and generated files
   
   - `jdbc-component.adoc`: new section "Using plain ? placeholders".
   - Upgrade guide 4.24: new `camel-jdbc, camel-spring-jdbc` entry.
   - `CamelJdbcParameters` header description and `javaType` (`Map` -> 
`Object`, as it can now be a List), the `useHeadersAsParameters` description 
and the `@BodyTypes` text are updated. Regenerated: jdbc.json, spring-jdbc.json 
(component and catalog), catalog jdbc-component.adoc, and the endpoint DSL 
builders.
   
   ## Not changed
   
   - `populateStatement` still ignores values beyond the number of placeholders 
(a List with too many values is not an error). It is shared with the named 
parameters path and kept as is.
   
   _Claude Code on behalf of Claus Ibsen (davsclaus)_
   
   🤖 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