My SQL files are all used as input to programmatic SQL. When you use most (all?) PG client libraries, you don't need to provide the semicolon because the interface only allows you to send a single statement. Similarly, psql -c 'select a from b' works. In these cases, I don't want an error about a missing semicolon at the end.
This PR adds a --add-semicolon flag. When it's passed
If you have a final semicolon already, nothing's changed
If you end inside a block comment, nothing's changed (the code is invalid, but adding a semicolon can't help)
If you end with a line comment, I add a newline + semicolon
Otherwise I add a semicolon
I wrote some tests for the new behavior (which is pretty simple, I think). I'd be happy to make other modifications or add more tests if you'd like.
My SQL files are all used as input to programmatic SQL. When you use most (all?) PG client libraries, you don't need to provide the semicolon because the interface only allows you to send a single statement. Similarly,
psql -c 'select a from b'
works. In these cases, I don't want an error about a missing semicolon at the end.This PR adds a
--add-semicolon
flag. When it's passedI wrote some tests for the new behavior (which is pretty simple, I think). I'd be happy to make other modifications or add more tests if you'd like.