You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "Jiri Ondrusek (Jira)" <ji...@apache.org> on 2023/01/11 14:44:00 UTC

[jira] [Commented] (CAMEL-18437) Camel-bigquery: There is a difference in types between @name and ${name}

    [ https://issues.apache.org/jira/browse/CAMEL-18437?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17675608#comment-17675608 ] 

Jiri Ondrusek commented on CAMEL-18437:
---------------------------------------

I started working on this issue, but I came to conclusion, that it cannot be changed in such way.  Example follows.

*Fix works in some cases like following one:*
User would like to use a sql query {code} insert into A(id, data) values(${id}, ${data}) {code}.
Following header are send in the exchange:

{code}
        exchange.getMessage().setHeader("id", 1);
        exchange.getMessage().setHeader("data", "test");
{code}

The result without the fix is *insert into A(id, data) values(1, test)*
With the fix the result is OK *insert into A(id, data) values(1, 'test')*

*But fix breaks different cases*:
In case  that sql is

{code}insert into A(id, data) values($values) {code}
with values {code}exchange.getMessage().setHeader("values", "1,2");{code}

The result would be (with fix) *insert into A(id, data)  values('1,2')*, which is wrong.

I'd say to keep the behavior as it is. What do you think [~davsclaus]




> Camel-bigquery: There is a difference in types between @name and ${name}
> ------------------------------------------------------------------------
>
>                 Key: CAMEL-18437
>                 URL: https://issues.apache.org/jira/browse/CAMEL-18437
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-google-bigquery
>    Affects Versions: 3.19.0
>            Reporter: Jiri Ondrusek
>            Assignee: Jiri Ondrusek
>            Priority: Minor
>             Fix For: 3.21.0
>
>
> I noticed a undefined behavior when expanding coverage of google-bigquery in camel-quarkus ([ticket|https://github.com/apache/camel-quarkus/issues/3949]).
>  
> Here is a relevant chapter from the [documentation|#_uri_format].]
>  
> {quote} * parameters in form ${name} are extracted from message headers and formed the translated query
>  * parameters in form @name are extracted from body or message headers and sent to Google Bigquery{quote}
> From my PoV is that in case of parameters in the header, it should not matter, whether _@name_ or _${name}_ is used.
> The behavior seems to be more complicated:
>  * In case of _@name_ pattern, value types are dynamically resolved (see https://issues.apache.org/jira/browse/CAMEL-18382 for more details)
>  * In case of {_}${name}{_}, value is inserted into the sql without any modification. Which behaves like "undefined".
>  # If header value is an integer (like 4), sql is translated into {_}... VALUES (4) ...{_}, so it is interpreted as integer.
>  # If header value is string with number inside (like "4"), sql is translated into {_}... VALUES (4) ...{_}, so it is interpreted as integer.
>  # If the header is string (like "s4"), sql is translated into {_}... VALUES (s4) ...{_}, and the execution fails.
> It would make sense that the behavior of _@name_ and _${name}_ is the same and mainly the case 3 does not cause any failure.



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