A SQL variation that allows for statements stacking. It is essentially syntax sugar for Common Table Expressions (the WITH clause).
- SQL is a widely adopted standard.
- We can only talk to PostgreSQL in SQL.
- I wish there were a few modifications.
- While the SQL committee does not approve my suggestions, we can transpile SoSql to SQL (and SQL to SoSql) using the binary provided here.
I hope the following examples are self-explanatory.
so
select * from auth_users
then
select name where id=64;
so
deleted_users <- delete from auth_users where not is_active returning *
then
delete from user_profile join deleted_users on (user_profile.user_id = deleted_users.id)
then
deleted_stats <- select now(), count(*) from deleted_users
then
insert into some_log (select * from deleted_stats)
so
from auth_users
so
from auth_users
then
where id=64;
so
from auth_users
group by language
fold [with] count(*);
The select clause is inferred from GROUP BY and FOLD clauses.
By default, we use stack+nix. If you have both installed, the following command will create a binary called sosql
in the appropriate path.
stack install
Installation without Nix should also work since we don't have external dependencies.
Alternatively, you can grab the binary in a zip file as an artifact of GitHub actions. Pick the last successful job, scroll down, and find the artifacts section.
- sosql -> sql
- sql -> sosql
- implicit from clause
- named statements
- unnamed statements
- implicit select clause
- improved aggregate clause
- implicit returning clause