Skip to content

Conversation

@rpaterson
Copy link

@codesandbox-ci
Copy link

codesandbox-ci bot commented Dec 9, 2025

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

@nene
Copy link
Collaborator

nene commented Dec 9, 2025

Thanks for the pull request.

Please describe what sort of issue you are trying to solve with this change.

FYI, this list of keywords that you edited is supposed to only include reserved keywords, and COMMENT is not a reserved keyword in PostgreSQL.

@rpaterson
Copy link
Author

rpaterson commented Dec 9, 2025 via email

@nene
Copy link
Collaborator

nene commented Dec 9, 2025

I think a better fix for this is to add COMMENT ON to the tabularOnelineClauses section in postgresql.formatter.ts

Though in general I should point out that SQL Formatter is fundamentally limited when it comes to distinguishing keywords from non-keywords, because it depends on the context whether something is a keyword or not. Like you could use comment as the name of a column or table, and then you would not want it to be capitalized. But because SQL Formatter doesn't fully parse the SQL, it can't tell the difference. And so there are many-many more keywords in PostgreSQL that this formatter isn't able to correctly identify as keywords.

@rpaterson
Copy link
Author

rpaterson commented Dec 9, 2025 via email

@nene
Copy link
Collaborator

nene commented Dec 9, 2025

I'd be happy to accept a PR with that change. For today I'm going to sleep :)

FYI, if you're looking for a formatter that doesn't have this sort of limitation, I suggest you check out prettier-plugin-sql-cst

nene added a commit that referenced this pull request Dec 10, 2025
@nene
Copy link
Collaborator

nene commented Dec 10, 2025

Fixed it myself. Closing this.

@nene nene closed this Dec 10, 2025
@rpaterson
Copy link
Author

Thank you!

@rpaterson rpaterson deleted the patch-1 branch December 10, 2025 09:05
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

Successfully merging this pull request may close these issues.

2 participants