jdorn / sql-formatter

A lightweight php class for formatting sql statements. Handles automatic indentation and syntax highlighting.
http://jdorn.github.com/sql-formatter/
MIT License
3.89k stars 187 forks source link

Incorrect formatting of DELIMITER. #104

Open vitalyspirin opened 6 years ago

vitalyspirin commented 6 years ago

1) ### Space is removed between DELIMITER and semicolon. If I execute

\SqlFormatter::format('DELIMITER ;');

Then I get DELIMITER;

My expectation is that space will be preserved after DELIMITER.

2) ### Error for forward slashes as DELIMITER. If I execute

\SqlFormatter::format('DELIMITER //')

then I get ErrorException "Uninitialized string offset: 1" line 217 in vendor/jdorn/sql-formatter/lib/SqlFormatter.php:

 if ($string[0] === '#' || (isset($string[1])&&($string[0]==='-'&&$string[1]==='-') || ($string[0]==='/'&&$string[1]==='*'))) {