Claus Ibsen created CAMEL-27893:
-----------------------------------
Summary: camel-sql: endpoint usePlaceholder has no effect on the
URI query, the consumer overrides maxRows, sql-stored batch evaluates
expressions on the whole exchange
Key: CAMEL-27893
URL: https://issues.apache.org/jira/browse/CAMEL-27893
Project: Camel
Issue Type: Bug
Components: camel-sql
Reporter: Claus Ibsen
Fix For: 4.25.0
Found while improving the option descriptions of camel-sql for CAMEL-23832
(pull request https://github.com/apache/camel/pull/31159).
These are separate problems of the component; the descriptions change only
documents the current behavior.
h4. 1. Endpoint usePlaceholder has no effect on the URI query
{{SqlComponent.createEndpoint}} replaces # with ? in the query and in
onConsume, onConsumeFailed and onConsumeBatchComplete with the usePlaceholder
of the component, before setProperties runs, so usePlaceholder=false on the
endpoint only affects a query from a resource and the CamelSqlQuery header.
Proposed change: do the replacement after setProperties with the endpoint
values.
h4. 2. The consumer overrides maxRows
{{SqlConsumer.setMaxMessagesPerPoll}} always calls
jdbcTemplate.setMaxRows(maxMessagesPerPoll), also when it is 0 (the default),
so it overwrites the maxRows of the template for the consumer.
Proposed change: only set it when maxMessagesPerPoll > 0.
h4. 3. sql-stored batch evaluates expressions on the whole exchange
With batch=true, the value extractor of InParameter for a ${...} expression
ignores the batch item and evaluates against the exchange, so every item gets
the same value; only :#name reads the item.
Proposed change: evaluate on a copy of the exchange with the batch item as
body, as SqlHelper.lookupParameter does.
h4. 4. outputHeader is set to null
{{SqlProducer.process}} sets the outputHeader also when there is no result (an
update, or batch=true).
Proposed change: only set it when there is data.
h4. 5. Generated keys are not read with StreamList
{{SqlProducer.processStreamList}} prepares the statement with
RETURN_GENERATED_KEYS when CamelSqlRetrieveGeneratedKeys=true, but never reads
the keys.
Proposed change: read them, or reject the header with StreamList.
_Claude Code on behalf of davsclaus_
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)