-
Notifications
You must be signed in to change notification settings - Fork 19
Open
Description
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:
pg-query-parser/src/deparser.js
Lines 269 to 273 in 1684b8f
| 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
Metadata
Metadata
Assignees
Labels
No labels