Passing arguments to SQL Builder

90 views
Skip to first unread message

Barry van der Veen

unread,
May 20, 2022, 10:55:45 AM5/20/22
to Fusio
Hi, i am using the SQL Builder action to create a nested JSON response from multiple tables. This works really well but I cannot find how to pass parameters from the route query string to the action. For example: if I pass ?mykey=123 to the action, how do I use the mykey in an where clause in the jql?

I have tried using {mykey} directly in the query like in the SQLSelectRow action but that does not work.
When I use "$params":{ "mykey":"mykey} that does not work either.

Is there a way to pass parameters to the SQL Builder action?

Kind Regards, 

Barry van der Veen

Christoph Kappestein

unread,
May 22, 2022, 2:03:36 PM5/22/22
to Fusio
Hi Barry,

yes so currently the builder does not support passing parameters from the request to the JQL but this would be indeed a very useful feature, currently you can basically only build standalone complex queries.
So I have also just created an issue for this s. https://github.com/apioo/fusio/issues/457 please feel free to add additional information.

best regards
Christoph

Pablo Mesquita

unread,
Jul 20, 2022, 11:28:19 AM7/20/22
to Fusio
Hello all..

i don't konw if my problem is the same that you are talking..
But I created a route using the class:  Fusio\Adapter\Sql\Action\Query\SqlQueryRow
I tested using the designer putting the parameter of filter in body of request using JSON everything works like a charm but if I send the same request through Postman I got this error:

"success": false,
    "title": "PSX\\Http\\Exception\\NotFoundException",
    "message": "Entry not found in /var/www/fusio/vendor/fusio/adapter-sql/src/Action/Query/SqlQueryRow.php on line 56",
    "trace": "#0 /var/www/fusio/vendor/fusio/engine/src/Processor.php(86): "
...."

but if i pass the same parameter in url everything works

It's the same problem ?

Christoph Kappestein

unread,
Jul 21, 2022, 2:11:36 PM7/21/22
to Fusio
Hi,

if so I think the problem is a different one, the initial post talks about the SqlBuilder action where you can configure a JSON to create a complex nested response s.

I think your problem is probably that your route has no :"id" fragment to get the fitting record?

best regards
Christoph

Barry van der Veen

unread,
Jul 25, 2022, 3:56:21 AM7/25/22
to Fusio
Hi Christoph,

I was diving into the code of the psx-sql JsonProvider to try to find out how to implement the needed functionality.
While reading I thought to myself "hmm, there already is a $contect entry in the parser, why won't that work at my installation?".
Then I saw that you modified the file yesterday :-) Thanks for that!

When will this change be available on docker-hub? Or would it be better to map the modified file using volumes in docker?

Kind regards, and thank you again!
Barry

Op donderdag 21 juli 2022 om 20:11:36 UTC+2 schreef christoph....@gmail.com:

Christoph Kappestein

unread,
Jul 25, 2022, 2:30:47 PM7/25/22
to Fusio
Hi Barry,

yes, no problem, I have adjusted the builder in preparation of our next release so that it is possible to accept parameters from the request. We have currently not a fix timeline for the next release but if the release is ready you can then simply update the docker image. If it is urgent you could also fix it directly but you would need to update multiple files, probably the fusio-adapter-sql and psx-sql vendor dependencies but this could result in other problems, the safe route would be to wait for the next release.

best regards
Christoph
Reply all
Reply to author
Forward
0 new messages