-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement prettier SQL unparsing (more human readable) #11186
Merged
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
c65d72a
initial prettier unparse
MohamedAbdeen21 1e25567
bug fix
MohamedAbdeen21 79532b9
handling minus and divide
MohamedAbdeen21 5c6aeca
cleaning references and comments
MohamedAbdeen21 dcc6664
moved tests
MohamedAbdeen21 29b5aa5
Update precedence of BETWEEN
MohamedAbdeen21 384dde1
rerun CI
MohamedAbdeen21 4d6967c
Change precedence to match PGSQLs
MohamedAbdeen21 2c8f5c4
more pretty unparser tests
MohamedAbdeen21 f753f05
Update operator precedence to match latest PGSQL
MohamedAbdeen21 912ce3a
directly prettify expr_to_sql
MohamedAbdeen21 eadc077
handle IS operator
MohamedAbdeen21 91d8b43
correct IS precedence
MohamedAbdeen21 c3dcb02
update unparser tests
MohamedAbdeen21 61fddb9
update unparser example
MohamedAbdeen21 38a04de
update more unparser examples
MohamedAbdeen21 98893f0
add with_pretty builder to unparser
MohamedAbdeen21 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -218,37 +218,33 @@ impl Operator { | |
} | ||
|
||
/// Get the operator precedence | ||
/// use <https://www.postgresql.org/docs/7.0/operators.htm#AEN2026> as a reference | ||
/// use <https://www.postgresql.org/docs/7.2/sql-precedence.html> as a reference | ||
pub fn precedence(&self) -> u8 { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It looks like this is only used in a few places for formatting the parenthesis in a |
||
match self { | ||
Operator::Or => 5, | ||
Operator::And => 10, | ||
Operator::NotEq | ||
| Operator::Eq | ||
| Operator::Lt | ||
| Operator::LtEq | ||
| Operator::Gt | ||
| Operator::GtEq => 20, | ||
Operator::Plus | Operator::Minus => 30, | ||
Operator::Multiply | Operator::Divide | Operator::Modulo => 40, | ||
Operator::Eq | Operator::NotEq | Operator::LtEq | Operator::GtEq => 15, | ||
Operator::Lt | Operator::Gt => 20, | ||
Operator::LikeMatch | ||
| Operator::NotLikeMatch | ||
| Operator::ILikeMatch | ||
| Operator::NotILikeMatch => 25, | ||
Operator::IsDistinctFrom | ||
| Operator::IsNotDistinctFrom | ||
| Operator::RegexMatch | ||
| Operator::RegexNotMatch | ||
| Operator::RegexIMatch | ||
| Operator::RegexNotIMatch | ||
| Operator::LikeMatch | ||
| Operator::ILikeMatch | ||
| Operator::NotLikeMatch | ||
| Operator::NotILikeMatch | ||
| Operator::BitwiseAnd | ||
| Operator::BitwiseOr | ||
| Operator::BitwiseShiftLeft | ||
| Operator::BitwiseShiftRight | ||
| Operator::BitwiseXor | ||
| Operator::StringConcat | ||
| Operator::AtArrow | ||
| Operator::ArrowAt => 0, | ||
| Operator::ArrowAt => 30, | ||
Operator::Plus | Operator::Minus => 40, | ||
Operator::Multiply | Operator::Divide | Operator::Modulo => 45, | ||
} | ||
} | ||
} | ||
|
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍