-
Notifications
You must be signed in to change notification settings - Fork 134
Questions on the SET
command
#877
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
SQLPage variables can only store scalar strings
It is expected. When you need to store more advanced data structures inside sqlpage, you can convert them to json first. You can store and use a list of ids like this: drop table if exists list;
create temp table list as select 1 as id union select 2 union select 3 union select 4;
-- store even numbers from the list as a json array in the $all variable
set all = (select json_group_array(id) from list where id % 2 = 0);
-- select only numbers present in the json array stored in 'all'
select 'list' as component;
select id as title
from list
where id in (select value from json_each($all)); Documenting SQLPage's SQL language extensions
That would be great, thank you very much ! It would indeed be very useful to systematically document how we parse and transform the sql files before passing them to the database. Below is a good starting point, which we could reformulate to be a little more pedagogical. sql language extensions
|
Hi! I currently don't have enough time to write it but I hope I'll have a first version in 2 weeks 🙂 |
Hi!
After trying to put a table-valued result in a
SET
variable, I think I understood that a SET variable can only store scalars, at least on SQLite:Here's a minimal example with SQLite:
Is it a current limitation, or is it expected?
Is
SET
a standard SQLite command? I can't find anything on it on the internet.And I guess there is some specific code on this command in
src/webserver/database/sql.rs
but I'm not quite sure.The only doc about this currently is in https://sql-page.com/your-first-sql-website/.
I feel like a documentation page "Extensions to SQL" would belong next to the "SQLPage functions" page, especially if there are other extensions than
SET
and the functions. I can contribute to the doc.What do you think about this? Did I go in the good direction or am I far from reality? Thanks!
The text was updated successfully, but these errors were encountered: