Claus Ibsen created CAMEL-25557:
-----------------------------------

             Summary: camel-jbang - sql: an insert-or-update in the dialect of 
another database than the datasource, and :#excluded.column as a named parameter
                 Key: CAMEL-25557
                 URL: https://issues.apache.org/jira/browse/CAMEL-25557
             Project: Camel
          Issue Type: Improvement
          Components: camel-jbang
            Reporter: Claus Ibsen
             Fix For: 4.24.0


In the local-model benchmark the connect-service-sql step that registers 
customers (insert, or add one to the order count of a customer already there) 
is the least stable step: it failed in 7 of 13 runs. The datasource of the 
example is PostgreSQL (spring.datasource.url=jdbc:postgresql:... in 
application.properties), and the model wrote:
* INSERT ... ON DUPLICATE KEY UPDATE orders = orders + 1 (MySQL): a syntax 
error for every file, 80-90 runtime errors, the model then tries other dialects 
until it runs out of tool calls;
* ON CONFLICT (id) DO UPDATE SET country = :#excluded.country: EXCLUDED is 
PostgreSQL's row being inserted, as a camel-sql named parameter it is a key 
looked up in the body and the headers.

Improvement (camel_write_file / camel_validate_source with the directory):
* When application.properties points to one PostgreSQL datasource, an INSERT 
... ON DUPLICATE KEY UPDATE says so and gives the statement to write: INSERT 
INTO customers (...) VALUES (...) ON CONFLICT (id) DO UPDATE SET orders = 
customers.orders + 1 (the key from a CREATE TABLE ... PRIMARY KEY in the same 
file when there is one; VALUES(col) as EXCLUDED.col). The other way round for a 
MySQL or MariaDB datasource and ON CONFLICT ... DO UPDATE.
* :#excluded.column in a sql: statement says EXCLUDED.column is written without 
:#.



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

Reply via email to