Skip to content

Bug - Column names with a only capital letters are not surrounded by quotes on deparse. #101

Closed
@ateszki

Description

@ateszki

Example

const parsed = parse('select "A" from "table_name");
const deparsed = deparse(parsed);
// departed is now 'select A from table_name'

const parsed = parse('select "AA" from "table_name");
const deparsed = deparse(parsed);
// departed is now 'select AA from table_name'

I think the fix would be to change the const needsQuotesRegex = /[a-z]+[\W\w]*[A-Z]+|[A-Z]+[\W\w]*[a-z]+|\W/; to
`const needsQuotesRegex = /[a-z]+[\W\w][A-Z]+|[A-Z]+[\W\w][a-z]+|\W|[A-Z]/;
At https://github.com/pyramation/pgsql-parser/blob/3d78dc66d800eb8cdf76851337f27b972160fb41/packages/deparser/src/deparser.js#L112C1-L112C71

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions