-
I did not realize SQLPage uses external SQL parser (perhaps, because I am not a Rust coder) . Could you elaborate on that? Is that a standard Rust component or a separate library/repo? It might be helpful to also have a reference in the "Technologies and libraries used" section of README.md. A somewhat related questions. The SQLPage docs mention that SQLPage is being smart about queries which do not need to be sent to the database. How about something like this: SELECT
'dynamic' AS component,
sqlpage.run_sql('footer_debug_post-get-set.sql') AS properties
WHERE $DEBUG OR $error IS NOT NULL; I want to load/run an SQL module conditionally based on whether certain GET parameter values or there availability. Above is my updated approach to showing POST/GET variables, where I put previously posted code in a separate module. Can I do it such that the condition is evaluated first and if false, the run_sql() call is skipped completely? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
About the parser: yes SQLPage needs to parse your SQL in order to:
The parser used is sqlparser-rs, which is very advanced, and supports even rarely-used database-specific syntax. I'm a contributor to it, so when we hit a corner case that is not yet supported, I implement it. |
Beta Was this translation helpful? Give feedback.
-
SELECT
'dynamic' AS component,
sqlpage.run_sql('footer_debug_post-get-set.sql') AS properties
WHERE $DEBUG OR $error IS NOT NULL; Currently, this does not work the way you might expect. The run_sql is executed unconditionally, then the sql statement is executed and returns 0 rows, so the dynamic component is not invoked. I am working on a smarter and more powerful function execution logic, you can have a look at opened pull requests if you are interested. In the meantime, if you want to conditionally execute a sqlpage function, you need to pass it a variable that has been previously defined to either null or the value you need. |
Beta Was this translation helpful? Give feedback.
Currently, this does not work the way you might expect. The run_sql is executed unconditionally, then the sql statement is executed and returns 0 rows, so the dynamic component is not invoked.
I am working on a smarter and more powerful function execution logic, you can have a look at opened pull requests if you are interested.
In the meantime, if you want to conditionally execute a sqlpage function, you need to pass it a variable that has been previously defined to either null or the value you need.