Dark Mode

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add PostgreSQL COMMENT keyword#924

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

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

Conversation

Copy link

rpaterson commented Dec 9, 2025

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.

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.

Copy link
Author

rpaterson commented Dec 9, 2025 via email

I have sql-formatter configured for PostgreSQL and to capitalize keywords, but it's not capitalising COMMENT.
...
On Tue, 9 Dec 2025, 7:36 pm Rene Saarsoo, ***@***.***> wrote: *nene* left a comment (sql-formatter-org/sql-formatter#924) <#924 (comment)> 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. -- Reply to this email directly, view it on GitHub <#924 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/ABOUMJDJFOY3NKZNBHN5OCT4A4QEJAVCNFSM6AAAAACORBFUT6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTMMZTHE2TGMZXHE> . You are receiving this because you authored the thread.Message ID: ***@***.***>

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.

Copy link
Author

rpaterson commented Dec 9, 2025 via email

Ok, would you like me to make that change or just close this PR as not supported?
...
On Tue, 9 Dec 2025, 9:19 pm Rene Saarsoo, ***@***.***> wrote: *nene* left a comment (sql-formatter-org/sql-formatter#924) <#924 (comment)> 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. -- Reply to this email directly, view it on GitHub <#924 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/ABOUMJGDIX2NQRDTXPJZAAD4A44HTAVCNFSM6AAAAACORBFUT6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTMMZUGMZDINZWGQ> . You are receiving this because you authored the thread.Message ID: ***@***.***>

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

nene commented Dec 10, 2025

Fixed it myself. Closing this.

nene closed this Dec 10, 2025
Copy link
Author

rpaterson commented Dec 10, 2025

Thank you!

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

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

2 participants