Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

run_sql parameters #1132

charlieglnp started this conversation in General
Discussion options

This has caught me out a few times - inclusion of parameters in the function call removes the ability to access the same variables as the calling page. Is this by design/as expected? The description of the function is slightly ambiguous and I initially interpreted it as passed parameters being additional to those available in the calling file.

E.g.

calling.sql

set test_var_1 = (select 1)
select 'text' as component, 'This is the calling file. Testing the variable: ' || $test_var_1 as contents;
select 'dynamic' as component, sqlpage.run_sql('include.sql', json_object('test_var_2', '2')) as properties;

include.sql

select 'text' as component, 'This is the inclusion file. Testing the variable: ' || $test_var_1 as contents;
You must be logged in to vote

Replies: 1 comment

Comment options

Yes, this is intentional.

You can use sqlpage.variables and merge existing variables with new ones, but I wouldn't recommend it. For future-proofing your code and making it easier to maintain and debug, it's usually better to explicitly name the parameters you are passing to run_sql.

Can you open a pull request with the changes you would like to see in the documentation to make it more explicit?

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet

AltStyle によって変換されたページ (->オリジナル) /