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:
|
if (node.colnames) { |
|
output.push(name + parens(this.list(node.colnames))); |
|
} else { |
|
output.push(this.quote(name)); |
|
} |
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
There is a bug in the
deparsefunction when outputting an Alias that hascolnames. It doesn't properly quote the alias name and the column names:pg-query-parser/src/deparser.js
Lines 269 to 273 in 1684b8f
The fix is to call
this.quoteon thename(just as is done in the "else" branch) as well asthis.quoteon all the column names.Here are 2 valid PostgreSQL queries that this library parses correctly, but deparse generates invalid output:
Incorrectly is deparsed to:
I can try to create a pull request