Skip to main content

Statement terminator

statementTerminator tells dfmt what ends a statement in a client script, when the client is run with something other than its own default terminator. It reads; it never writes. dfmt does not insert or change terminators. It only needs to know where one statement ends and the next begins, because every option that acts between statements acts on the boundaries this defines, and a script whose statements end in ! reads as one enormous statement until it is told.

Default: unset, meaning the client's own default: ; for psql and the db2 command line, GO on a line of its own for sqlcmd, ; or / for SQL*Plus. Most scripts need nothing.

Set it when the invocation says otherwise. db2 -td! makes the terminator !, mysql --delimiter=// makes it //, sqlcmd -c cmd_end replaces GO. That instruction lives on the command line, not in the file, so the formatter cannot find it out for itself. Put it under the dialect's section of dlab.json, since a terminator is a fact about one client:

{
"dfmt": {
"db2": { "statementTerminator": "!" }
}
}

A file's own directive (--#SET TERMINATOR ! for db2, DELIMITER // for mysql) overrides the option from the point where it appears.

Where it is refused. On a dialect whose client has no such option, setting it fails by name rather than being ignored. In a dbt, Flyway or schemachange project it is refused too: those tools decide statement boundaries in their own parsers, and a value here would describe a client that never reads the file.

There is no example on this page. An example here formats a statement that has already been split out of its script, so none can show the option at work. It is tested at the point where a script is split.