[
https://issues.apache.org/jira/browse/CAMEL-27147?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18146569#comment-18146569
]
Claus Ibsen commented on CAMEL-27147:
-------------------------------------
PR: https://github.com/apache/camel/pull/30319
_Claude Code on behalf of Claus Ibsen_
> camel-cassandraql - bind named markers (:name) from a Map body
> --------------------------------------------------------------
>
> Key: CAMEL-27147
> URL: https://issues.apache.org/jira/browse/CAMEL-27147
> Project: Camel
> Issue Type: Improvement
> Components: camel-cassandraql
> Reporter: Claus Ibsen
> Assignee: Claus Ibsen
> Priority: Minor
> Fix For: 4.24.0
>
>
> The cql producer takes the values of the bind markers of a statement only by
> position. The body is an Object[], a Collection or a single value
> (CassandraProducer.getCqlParams), so a statement is written with ? markers
> and the body must list the values in that order:
> {code}
> INSERT INTO accounts (id, username, city) VALUES (?, ?, ?)
> body: [1, "oscerd", "Rome"]
> {code}
> A Map body is bound as one single value, so there is no way to bind by name.
> CQL and the Cassandra Java driver have named bind markers (:name). This adds
> support for a Map body: each named marker takes the value of the Map entry of
> that name.
> {code}
> INSERT INTO accounts (id, username, city) VALUES (:id, :username, :city)
> body: {"id": 1, "username": "oscerd", "city": "Rome"}
> {code}
> * prepareStatements=true (the default): the values are taken from the Map in
> the order of PreparedStatement.getVariableDefinitions(), and bound as today.
> * prepareStatements=false: SimpleStatement with named values.
> * A marker with no Map entry fails with a clear message that names the marker.
> * An Object[], a Collection or a single value binds by position, as before.
> This is what the SQL component does with :#name and a Map body, and what the
> SQL Kamelets use. The Kamelet cassandra-sink takes a JSON array today and
> will take a JSON object once this is in (apache/camel-kamelets).
> _Claude Code on behalf of Claus Ibsen_
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)