Skip to content

Missing quoting in 'Alias' deparse #17

@benny-medflyt

Description

@benny-medflyt

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions