fix: remove extra space after BETWEEN _ AND _ expression#959
Open
sarathfrancis90 wants to merge 1 commit into
Open
fix: remove extra space after BETWEEN _ AND _ expression#959sarathfrancis90 wants to merge 1 commit into
sarathfrancis90 wants to merge 1 commit into
Conversation
The whitespace between the upper bound of a BETWEEN predicate and
whatever follows it was doubled, because the sub-expression already
emits a trailing space and formatBetweenPredicate added another one on
top. It shows up with default options, e.g.
SELECT CASE WHEN foo BETWEEN 1 AND 2 THEN 3 END
produced "WHEN foo BETWEEN 1 AND 2 THEN 3".
Normalize the trailing whitespace the same way the lower bound already
does, with NO_SPACE followed by SPACE.
Contributor
📝 WalkthroughWalkthroughThe formatter changes whitespace token emission after ChangesBETWEEN whitespace correction
Estimated code review effort: 2 (Simple) | ~10 minutes Suggested reviewers: 🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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.
I noticed the formatter emits two spaces after a BETWEEN predicate whenever something follows it on the same line. With default options:
gives
WHEN foo BETWEEN 1 AND 2 THEN 3. Same forlogicalOperatorNewline: 'after'(b BETWEEN 1 AND 2 AND) and forb BETWEEN 1 AND 2 IS TRUE.The cause is in
formatBetweenPredicate: the sub-expression for the upper bound already ends with a trailing space, and the method then adds anotherWS.SPACEon top. It usually goes unnoticed because with the defaultlogicalOperatorNewline: 'before'the followingWS.NEWLINEtrims the doubled space away. The lower bound already normalizes this withWS.NO_SPACE, WS.SPACE, so I did the same for the upper bound.Two existing expectations had the extra space baked in (
test/features/between.tsandtest/features/case.ts); both are updated to the intended single space.Tested with
pnpm run check(typecheck, prettier, eslint, full jest suite) — all green. I also re-ran a format/re-format idempotency sweep over the repo's own test queries across every dialect and the option matrix; nothing changed apart from the removed space.