Skip to content

feat: comments for all operators #917

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

Merged
merged 1 commit into from
Jul 17, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions src/ast/operator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,11 @@ use super::display_separated;
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "visitor", derive(Visit, VisitMut))]
pub enum UnaryOperator {
/// Plus, e.g. `+9`
Plus,
/// Minus, e.g. `-9`
Minus,
/// Not, e.g. `NOT(true)`
Not,
/// Bitwise Not, e.g. `~9` (PostgreSQL-specific)
PGBitwiseNot,
Expand Down Expand Up @@ -66,39 +69,67 @@ impl fmt::Display for UnaryOperator {
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "visitor", derive(Visit, VisitMut))]
pub enum BinaryOperator {
/// Plus, e.g. `a + b`
Plus,
/// Minus, e.g. `a - b`
Minus,
/// Multiply, e.g. `a * b`
Multiply,
/// Divide, e.g. `a / b`
Divide,
/// Modulo, e.g. `a % b`
Modulo,
/// String/Array Concat operator, e.g. `a || b`
StringConcat,
/// Greater than, e.g. `a > b`
Gt,
/// Less than, e.g. `a < b`
Lt,
/// Greater equal, e.g. `a >= b`
GtEq,
/// Less equal, e.g. `a <= b`
LtEq,
/// Spaceship, e.g. `a <=> b`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀 -- I didn't even know about this one

Spaceship,
/// Equal, e.g. `a = b`
Eq,
/// Not equal, e.g. `a <> b`
NotEq,
/// And, e.g. `a AND b`
And,
/// Or, e.g. `a OR b`
Or,
/// XOR, e.g. `a XOR b`
Xor,
/// Bitwise or, e.g. `a | b`
BitwiseOr,
/// Bitwise and, e.g. `a & b`
BitwiseAnd,
/// Bitwise XOR, e.g. `a ^ b`
BitwiseXor,
/// Integer division operator `//` in DuckDB
DuckIntegerDivide,
/// MySQL [`DIV`](https://dev.mysql.com/doc/refman/8.0/en/arithmetic-functions.html) integer division
MyIntegerDivide,
/// Support for custom operators (built by parsers outside this crate)
Custom(String),
/// Bitwise XOR, e.g. `a # b` (PostgreSQL-specific)
PGBitwiseXor,
/// Bitwise shift left, e.g. `a << b` (PostgreSQL-specific)
PGBitwiseShiftLeft,
/// Bitwise shift right, e.g. `a >> b` (PostgreSQL-specific)
PGBitwiseShiftRight,
/// Exponent, e.g. `a ^ b` (PostgreSQL-specific)
PGExp,
/// Overlap operator, e.g. `a && b` (PostgreSQL-specific)
PGOverlap,
/// String matches regular expression (case sensitively), e.g. `a ~ b` (PostgreSQL-specific)
PGRegexMatch,
/// String matches regular expression (case insensitively), e.g. `a ~* b` (PostgreSQL-specific)
PGRegexIMatch,
/// String does not match regular expression (case sensitively), e.g. `a !~ b` (PostgreSQL-specific)
PGRegexNotMatch,
/// String does not match regular expression (case insensitively), e.g. `a !~* b` (PostgreSQL-specific)
PGRegexNotIMatch,
/// PostgreSQL-specific custom operator.
///
Expand Down