sqlpage / SQLPage

Fast SQL-only data application builder. Automatically build a UI on top of SQL queries.
https://sql.datapage.app
MIT License
1.57k stars 89 forks source link

(feature) add sqlpage.query_string() #486

Closed guspower closed 3 months ago

guspower commented 3 months ago

Adds the sqlpage.query_string() SQLPage function.

There are a few auth-related scenarios where it is useful to be able to directly access the query string and propagate it, for example when redirecting to a login page from a url with query string, and then redirecting the user back to that url on successful login.

There may be better ways to do this, but here is a simple query_string function for your consideration.

lovasoa commented 3 months ago

Thank you for the pull request !

I am not a huge fan of duplicating the entire query string (which can be large) into memory just for the use of one new function...

What would you think about taking the variables as an argument, in the form of a json object ? That would make the function more generally useful, and one would still be able to do

sqlpage.query_string(sqlpage.variables('get'))
guspower commented 3 months ago

Yep that seems reasonable - in fact it was what I started out doing but then realized that I'd have to take a perspective on both ordering and encoding. Let me rework this later in the week and come back to you with something that fits.

lovasoa commented 3 months ago

@guspower , what do you think about doing this instead: https://github.com/lovasoa/SQLpage/pull/494 ?

guspower commented 3 months ago

Yep that looks good to me. Much cleaner +1