GomorraSQL

From Esolang
Jump to navigation Jump to search
GomorraSQL
Paradigm(s) Declarative
Designed by Donato Rimenti
Appeared in 2021
Computational class Finite state automata
Reference implementation GomorraSQL
Influenced by LOLCODE
File extension(s) none

GomorraSQL is an interpreted SQL language that replaces the standard keywords with Neapolitan Language. It's available as a Java library or an executable shell.

Syntax

Likewise standard SQL, GomorraSQL allows performing data manipulation. Here's a list of supported operations:

Retrieving data

To retrieve data, you can use the ripigliammo command. Here's the command syntax:

ripigliammo (<comma_separated_column_names> || tutto chillo ch'era 'o nuostro) mmiez 'a <table_name> [pesc e pesc <table_name>...] [arò <condition>]

The first argument for the ripigliammo command is the columns to retrieve. They can be specified either as a list of comma-separated values or with the tutto chillo ch'era 'o nuostro which will return all the columns.

After the columns, the following parameter is the name of the table where to fetch the data with mmiez 'a. Data can be fetched from multiple tables by using the optional join operator pesc e pesc followed by another table name. Currently, there's no limit on the number of pesc e pesc that can be applied to a single ripigliammo. The join condition is specified in the arò clause, along with the row filtering.

Finally, you can filter the rows using the optional arò clause, followed by one or more conditions. The conditions work exactly like in SQL, with a slightly different syntax for some operators (check the [Language Reference](#language-reference) section).

Sample queries

Retrieve all users' data:

ripigliammo tutto chillo ch'era 'o nuostro mmiez 'a user

Retrieve all the emails of the users with id 6 or null name:

ripigliammo email mmiez 'a user arò id = 6 o name è nisciun

Retrieve the data of the user with id 6 along joined with his birth city and his account data:

ripigliammo email mmiez 'a user pesc e pesc city pesc e pesc account arò user.id = 6 e user.birth_city = city.id e user.account_id = account.id

Deleting data

Data deletion can be performed using the facimm na' strage command which supports a subset of options from the ripigliammo command. Here's the syntax:

facimm na' strage mmiez 'a <table_name> [arò <condition>]

Sample queries

Delete all users' data:

facimm na' strage mmiez 'a user

Delete the users with name not null or with deleted = true:

facimm na' strage mmiez 'a user arò name nun è nisciun o deleted è true

Updating data

The command rifacimm is used to update data in a table. The syntax is:

rifacimm <table_name> accunza <column_1> accussì <value_1>, <column_2> accussì <value_2>, ... [arò <conditions>]

The accunza operator marks the begin of a list of column/values assignments using the assignment operator accussì.

Sample queries

Set the name "Pippo" for all the users:

rifacimm user accunza name accussì "Pippo"

Set the name to "Pinco" and surname to "Pallo" for all users with null name:

rifacimm user accunza name accussì "Pinco", surname accussì "Pallo" arò name è nisciun

Inserting data

Data insertion can be performed using the nzipp 'ngoppa operator as following:

nzipp 'ngoppa <table_name> (<column_1>, <column_2>...) chist <value_1>, <value_2>...

After the table name, you can specify a list of columns whose data are being inserted. If not present, GomorraSQL will default to all columns. The chist keyword marks the beginning of a comma-separated list of values to insert. Each insert statement can only add one row.

Sample queries

Insert a new user with all his data:

nzipp 'ngoppa user chist 1, "Pinco", "Pallo"

Insert a new user with only his name set:

nzipp 'ngoppa user name chist "Pinco"

Transaction support

Being a fully ACID compliant language, GomorraSQL offers basic transaction management. To begin a transaction, you can issue the command ua uagliò. You can then commit the transaction with the command iamme bello ia' or perform rollback with the command sfaccimm.

Keywords

GomorraSQL syntax is mapped to standard SQL according to the following table:

GomorraSQL keyword SQL equivalent Valid in...
ripigliammo SELECT SELECT
rifacimm UPDATE UPDATE
nzipp INSERT INSERT
'ngoppa INTO INSERT
facimm na' strage DELETE DELETE
pesc e pesc INNER JOIN SELECT
mmiez 'a FROM SELECT, DELETE
tutto chillo ch'era 'o nuostro * SELECT
arò WHERE SELECT, UPDATE, DELETE
e AND ANY WHERE CLAUSE
o OR ANY WHERE CLAUSE
nisciun NULL ANY WHERE CLAUSE
è IS ANY WHERE CLAUSE
nun è IS NOT ANY WHERE CLAUSE
chist VALUES INSERT
accunza SET UPDATE
accussì = (assignment) UPDATE
> > ANY WHERE CLAUSE
< < ANY WHERE CLAUSE
= (comparison) = (comparison) ANY WHERE CLAUSE
!= != ANY WHERE CLAUSE
<> <> ANY WHERE CLAUSE
<= <= ANY WHERE CLAUSE
>= >= ANY WHERE CLAUSE
sfaccimm ROLLBACK TRANSACTION
iamme bello ia' COMMIT TRANSACTION
ua uagliò BEGIN TRANSACTION TRANSACTION

Supported Database

GomorraSQL has been tested with MySQL and H2 and other databases may not work properly.