Render prefix ~ operator with a space - #2533
Merged
Merged
Conversation
LucaCappelletti94
marked this pull request as ready for review
September 19, 2026 20:37
6 tasks
alamb
approved these changes
Sep 21, 2026
| @@ -1961,6 +1961,7 @@ impl fmt::Display for Expr { | |||
| } else if matches!( | |||
Contributor
There was a problem hiding this comment.
As a stylistic suggestion here to avoid issues in the future, I suggest changing the structure of this code to a sigle match so we can explicitly see which operators are handled in what form
like
match op {
UnaryOperator::PGPostfixFactorial => write!(f, "{expr}{op}"),
UnaryOperator::Not
| UnaryOperator::BitwiseNot
| UnaryOperator::Hash
| UnaryOperator::AtDashAt
| UnaryOperator::DoubleAt
| UnaryOperator::QuestionDash
| UnaryOperator::QuestionPipe => write!(f, "{op} {expr}"
// TODO explcitly list out the other operators here so the list is explicitl
}Also when I was typing that it seems like UnaryOperator::PGPostfixFactorial is the same as the else match 🤔
LucaCappelletti94
force-pushed
the
postgres-pgbitnot-display-space
branch
from
September 21, 2026 13:21
199e401 to
a2345b2
Compare
alamb
approved these changes
Sep 21, 2026
| | UnaryOperator::PGAbs | ||
| | UnaryOperator::QuestionDash | ||
| | UnaryOperator::QuestionPipe => write!(f, "{op} {expr}"), | ||
| UnaryOperator::Plus |
Contributor
|
Nice -- thank you @LucaCappelletti94 |
github-merge-queue
Bot
removed this pull request from the merge queue due to no response for status checks
Sep 21, 2026
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.
Fuzz round-trip found
SELECT ~ -1rendering asSELECT ~-1, which PostgreSQL retokenizes as the single~-custom operator and fails to re-parse.SELECT ~ ~1rendersSELECT ~~1and fails in every dialect,~ @2renders~@2and~ #xrenders~# xin PostgreSQL.Expr::UnaryOpdisplay concatenates operator and operand in its final arm.BitwiseNotjoins the spaced arm besideNotandHash, the same remedy #2531 applies to@. Canonical output forSELECT ~exprbecomesSELECT ~ expr, pinned withone_statement_parses_toinparse_generic_unary_ops.