Skip to content

Add PostgreSQL COMMENT keyword#924

Closed
rpaterson wants to merge 1 commit into
sql-formatter-org:masterfrom
rpaterson:patch-1
Closed

Add PostgreSQL COMMENT keyword#924
rpaterson wants to merge 1 commit into
sql-formatter-org:masterfrom
rpaterson:patch-1

Conversation

@rpaterson

Copy link
Copy Markdown

@codesandbox-ci

codesandbox-ci Bot commented Dec 9, 2025

Copy link
Copy Markdown

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

nene commented Dec 9, 2025

Copy link
Copy Markdown
Collaborator

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

rpaterson commented Dec 9, 2025 via email

Copy link
Copy Markdown
Author

@nene

nene commented Dec 9, 2025

Copy link
Copy Markdown
Collaborator

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

rpaterson commented Dec 9, 2025 via email

Copy link
Copy Markdown
Author

@nene

nene commented Dec 9, 2025

Copy link
Copy Markdown
Collaborator

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

nene commented Dec 10, 2025

Copy link
Copy Markdown
Collaborator

Fixed it myself. Closing this.

@nene nene closed this Dec 10, 2025
@rpaterson

Copy link
Copy Markdown
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