pg-query-parser
pg-query-parser copied to clipboard
Missing quoting in 'Alias' deparse
There is a bug in the deparse function when outputting an Alias that has colnames. It doesn't properly quote the alias name and the column names:
The fix is to call this.quote on the name (just as is done in the "else" branch) as well as this.quote on all the column names.
Here are 2 valid PostgreSQL queries that this library parses correctly, but deparse generates invalid output:
SELECT * FROM generate_series(1, 1) "a#b";
SELECT * FROM generate_series(1, 1) "a#b"("c#d");
Incorrectly is deparsed to:
SELECT * FROM generate_series(1, 1) AS a#b;
SELECT * FROM generate_series(1, 1) AS a#b(c#d);
I can try to create a pull request
I found a similar problem with SQL OVER clauses:
It should be output.push(this.quote(name));
@benny-medflyt is this still an issue?
if it is, make a PR to my fork and I'll merge and publish https://github.com/pyramation/pgsql-parser
@benny-medflyt fixed: https://github.com/pyramation/pgsql-parser/commit/ec36490546712b9301b0ef4a87f7fdf46a7f9453