Skip to main content
Michael Fesser 님이 #MuleSoft DataWeave에 질문했습니다

We have written code to parameterize select queries based on what the user passes in as the query parameters. 

 

In this case just assume vars.query is something like "SELECT * FROM table" for simplicity sake

 

When you put #\[vars.query\] in the SQL Query Text of the Query window for a normal Select query you get a null value for the SQL parameter error.

 

Functionally there is no issue as the query runs fine. The main issue is that if shows a nice big red X on the flow which would confuse other developers.

 

You can avoid the error by doing something like #\[vars.query default 'SELECT * FROM table'\] but that is hardly ideal since the whole point it to not have to have any text in there. Also because mule looks for the metadata you can't just put '' or something in there.

 

Is there any way to convince datasense that the data is there, find a simple "default" or find a syntax that will work correctly.

답변 2개
  1. 2023년 7월 13일 오전 12:45

    I might have been a bit to brief in my example

     

    'SELECT * FROM employee WHERE firstName = :firstName'

     

    is an example of what it builds, so the input params are still used. They are just always the "query" parameters passed in, ie query or uri.

     

    I did try the metadata, it did not seem to apply to the sql itself. It could be done for the input parameters. Even at the element and flow level it seemed to not see the metadata.

     

    Also tried default ''. It errors out on there being an empty string.

     

    Dataweave being evil on this one.

0/9000