Strata · API
sqlSteps
sqlSteps splits a DDL file into one sql step per statement, because a driver that prepares statements rejects a string that contains several. It splits only where a ; ends a line of SQL: a semicolon inside a comment does not split, and a statement may span several lines. A comment stays with the statement that follows it.
-- the programme; one row a night CREATE TABLE shows (night date PRIMARY KEY, title text NOT NULL); CREATE TABLE passes ( member text PRIMARY KEY, amount_cents int NOT NULL );
[
{
kind: 'sql',
sql: [
'-- the programme; one row a night',
'CREATE TABLE shows (night date PRIMARY KEY, title text NOT NULL)',
],
},
{
kind: 'sql',
sql: [
'CREATE TABLE passes (',
' member text PRIMARY KEY,',
' amount_cents int NOT NULL',
')',
],
},
]Runs in this page on the installed package. The input and the expected output are defined by the example.