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/
PostgreSQL License
1.66k stars 100 forks source link

Using pgformatter in dbeaver, formatting error #341

Closed NewBody-LC closed 2 months ago

NewBody-LC commented 2 months ago

Using pgformatter in dbeaver, a separate formatter inside the exists parentheses will not give an error, but SQL cannot be formatted as shown below. The error message is as follows

SQL:select * from ta mm where 1=1 and exists (SELECT 1 FROM table1 a
INNER JOIN table2 ct ON
((ct.c1=a.c1 AND lev=1) OR (a.c2 IS NULL AND ct.c1=a.c1) OR (a.c2 IS NOT NULL AND ct.c1=a.c2)) AND mm.id=a.id)

ERROR: Uncaught exception: Use of uninitialized value in pattern match (m//) at D:/Program Files/pgFormatter-5.5/lib/pgFormatter/Beautify.pm line 968, line 1. at D:\Program Files\pgFormatter-5.5\pg_format line 19, line 1. main::ANON("Use of uninitialized value in pattern match (m//) at D:/Progr"...) called at D:/Program Files/pgFormatter-5.5/lib/pgFormatter/Beautify.pm line 968 pgFormatter::Beautify::beautify(pgFormatter::Beautify=HASH(0x1a9ffd2e5f0)) called at D:/Program Files/pgFormatter-5.5/lib/pgFormatter/CLI.pm line 170 pgFormatter::CLI::beautify(pgFormatter::CLI=HASH(0x1a9fd5ac170)) called at D:/Program Files/pgFormatter-5.5/lib/pgFormatter/CLI.pm line 78 pgFormatter::CLI::run(pgFormatter::CLI=HASH(0x1a9fd5ac170)) called at D:\Program Files\pgFormatter-5.5\pg_format line 49

darold commented 2 months ago

Please use latest development code and try to reproduce. It looks to not have the problem.

NewBody-LC commented 2 months ago

use latest development code is ok. thanks bro. Niubility