You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "Claus Ibsen (Jira)" <ji...@apache.org> on 2026/09/26 10:03:00 UTC

[jira] [Created] (CAMEL-25039) camel-sql - say when a query uses a named parameter without the # placeholder instead of passing it to the database

Claus Ibsen created CAMEL-25039:
-----------------------------------

             Summary: camel-sql - say when a query uses a named parameter without the # placeholder instead of passing it to the database
                 Key: CAMEL-25039
                 URL: https://issues.apache.org/jira/browse/CAMEL-25039
             Project: Camel
          Issue Type: Improvement
          Components: camel-sql
            Reporter: Claus Ibsen


The sql component takes named parameters as {{:#name}} or {{:#${simple}}}. A query that uses any other shape is passed through to the database untouched, and the database's complaint names neither Camel nor the right syntax.

{{DefaultSqlPrepareStatementStrategy.prepareQuery}} asks {{hasNamedParameters(query)}} and, when the answer is no, returns the query unchanged:

{code:java}
if (allowNamedParameters && hasNamedParameters(query)) {
    ...
    answer = replaceParams(query);
} else {
    answer = query;
}
{code}

The patterns it parses are {{:?name}} / {{:?${...}}} -- {{SqlComponent}} has already regex-replaced the {{placeholder}} character ({{#}} by default) with {{?}}. So {{:customer}} and {{:${body[customer]}}} match nothing, reach H2 verbatim, and come back as:

{noformat}
Syntax error in SQL statement "INSERT INTO customers (id, country, orders) VALUES ([*]:$ body[customer] , :$ body[country] , 1) ..."
{noformat}

(the braces are blanked by H2's own JDBC-escape handling, which makes the message harder still to connect back to the query as written).

Suggestion: when the query is passed through because nothing was recognised, but it contains a {{:}} followed by a letter or {{$}}, say so once -- either a WARN when the endpoint starts or a hint added to the failure -- naming the supported form. It should stay a hint and never reject a query: a colon appears legitimately in a Postgres {{::}} cast and in time literals, so the check must skip a doubled colon and must not fail the endpoint.

Evidence: measuring how well a local model writes Camel routes, a step that registers a row with named parameters was failed by all 20 attempts across two 10-pass runs. The attempts were {{:customer}} (Spring JDBC style, no {{#}}), {{:${body[customer]}}} (no {{#}}), and the correct {{:#${body[customer]}}} paired with a MySQL-dialect upsert. Only the last of those is the author's own fault; the first two are shapes Camel could recognise as a mistake and name.

See also the sibling issue about the catalog documentation of a component not carrying the syntax at all, only the option list.




--
This message was sent by Atlassian Jira
(v8.20.10#820010)