Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
ateszki opened this issue Oct 3, 2023 · 0 comments

Comments

@ateszki
Copy link

ateszki commented Oct 3, 2023

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

@ateszki ateszki changed the title Bug - Column names with a single capital letter are not surrounded by quotes on deparse. Bug - Column names with a only capital lettersa re not surrounded by quotes on deparse. Oct 3, 2023
@ateszki ateszki changed the title Bug - Column names with a only capital lettersa re not surrounded by quotes on deparse. Bug - Column names with a only capital letters are not surrounded by quotes on deparse. Oct 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant