darold / pgFormatter

A PostgreSQL SQL syntax beautifier that can work as a console program or as a CGI. On-line demo site at http://sqlformat.darold.net/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Bug] Formatting "exists" statement

bogdan opened this issue · comments

Any use of EXISTS keyword causes an error:

$ echo "SELECT * FROM companies WHERE EXISTS (SELECT 1)" | pg_format
Uncaught exception: Use of uninitialized value in pattern match (m//) at /usr/local/Cellar/pgformatter/5.5/libexec/lib/pgFormatter/Beautify.pm line 968, <STDIN> line 1.
 at /usr/local/bin/pg_format line 19, <STDIN> line 1.
	main::__ANON__("Use of uninitialized value in pattern match (m//) at /usr/loc"...) called at /usr/local/Cellar/pgformatter/5.5/libexec/lib/pgFormatter/Beautify.pm line 968
	pgFormatter::Beautify::beautify(pgFormatter::Beautify=HASH(0x7f7996c273f8)) called at /usr/local/Cellar/pgformatter/5.5/libexec/lib/pgFormatter/CLI.pm line 170
	pgFormatter::CLI::beautify(pgFormatter::CLI=HASH(0x7f799600be28)) called at /usr/local/Cellar/pgformatter/5.5/libexec/lib/pgFormatter/CLI.pm line 78
	pgFormatter::CLI::run(pgFormatter::CLI=HASH(0x7f799600be28)) called at /usr/local/bin/pg_format line 49

Just hit a similar failure. FWIW, adding the ; at the end fixes things:

$ echo "SELECT * FROM companies WHERE EXISTS (SELECT 1);" | pg_format
SELECT
    *
FROM
    companies
WHERE
    EXISTS (
        SELECT
            1);

I'm not able to reproduce the problem using latest development code:

$ echo "SELECT * FROM companies WHERE EXISTS (SELECT 1)" | pg_format
SELECT
    *
FROM
    companies
WHERE
    EXISTS (
        SELECT
            1)

yeah, I was definitely on v5.5.

Ahhh should have checked the issues in more detail. I ran into this as well, reduced it to the EXISTS and figured out that the semi-colon at the end fixed it.
I've checked, and it's v5.5 where I'm hitting the issue. Let me just double check latest devel.

Yep, can confirm that the issue is fixed (for me) on the latest master.

Are there any plans to cut a release any time soon?

I can try to push a new release this weekend.