fix: format PostgreSQL CREATE POLICY commands consistently - #2
Draft
cnbei wants to merge 1 commit into
Draft
Conversation
Recognize FOR {SELECT|INSERT|DELETE} as clauses and WITH CHECK as a
keyword phrase so SELECT vs INSERT policies no longer wrap differently.
Co-authored-by: cnbei <baymy@foxmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes sql-formatter-org#928
SELECTwas tokenized asreservedSelectandWITHas a CTE clause, so two similarCREATE POLICYstatements wrapped differently:FOR SELECTsplit intoFOR+ a newSELECTclauseFOR INSERT ... WITH CHECKkeptFOR INSERTtogether, then started aWITHclauseDetect
FOR {SELECT | INSERT | DELETE}as reserved clauses (next to the existingFOR UPDATElocking clause) andWITH CHECKas a keyword phrase (likeWITH ORDINALITY).FOR SELECTandFOR INSERTnow use the same layout.Upstream compare (please open the PR here):
https://github.com/sql-formatter-org/sql-formatter/compare/master...cnbei:sql-formatter:cursor/pg-create-policy-format-dfe8?expand=1
gh pr create --repo sql-formatter-org/sql-formatter --head cnbei:cursor/pg-create-policy-format-dfe8failed withResource not accessible by integration.Tests
pnpm exec jest test/postgresql.test.ts --coverage=false— 462 passed.