Return the operator where swapping lhs and rhs wouldn't change the result. For example `Binary(50, >=, a)` could also be represented as `Binary(a, <=, 50)`.
(&self)
| 246 | /// |
| 247 | /// For example `Binary(50, >=, a)` could also be represented as `Binary(a, <=, 50)`. |
| 248 | pub fn swap(&self) -> Option<Operator> { |
| 249 | match self { |
| 250 | Operator::Eq => Some(Operator::Eq), |
| 251 | Operator::NotEq => Some(Operator::NotEq), |
| 252 | Operator::Lt => Some(Operator::Gt), |
| 253 | Operator::LtEq => Some(Operator::GtEq), |
| 254 | Operator::Gt => Some(Operator::Lt), |
| 255 | Operator::GtEq => Some(Operator::LtEq), |
| 256 | Operator::AtArrow => Some(Operator::ArrowAt), |
| 257 | Operator::ArrowAt => Some(Operator::AtArrow), |
| 258 | Operator::IsDistinctFrom => Some(Operator::IsDistinctFrom), |
| 259 | Operator::IsNotDistinctFrom => Some(Operator::IsNotDistinctFrom), |
| 260 | Operator::Plus |
| 261 | | Operator::Minus |
| 262 | | Operator::Multiply |
| 263 | | Operator::Divide |
| 264 | | Operator::Modulo |
| 265 | | Operator::And |
| 266 | | Operator::Or |
| 267 | | Operator::RegexMatch |
| 268 | | Operator::RegexIMatch |
| 269 | | Operator::RegexNotMatch |
| 270 | | Operator::RegexNotIMatch |
| 271 | | Operator::LikeMatch |
| 272 | | Operator::ILikeMatch |
| 273 | | Operator::NotLikeMatch |
| 274 | | Operator::NotILikeMatch |
| 275 | | Operator::BitwiseAnd |
| 276 | | Operator::BitwiseOr |
| 277 | | Operator::BitwiseXor |
| 278 | | Operator::BitwiseShiftRight |
| 279 | | Operator::BitwiseShiftLeft |
| 280 | | Operator::StringConcat |
| 281 | | Operator::Arrow |
| 282 | | Operator::LongArrow |
| 283 | | Operator::HashArrow |
| 284 | | Operator::HashLongArrow |
| 285 | | Operator::AtAt |
| 286 | | Operator::IntegerDivide |
| 287 | | Operator::HashMinus |
| 288 | | Operator::AtQuestion |
| 289 | | Operator::Question |
| 290 | | Operator::QuestionAnd |
| 291 | | Operator::QuestionPipe |
| 292 | | Operator::Colon => None, |
| 293 | } |
| 294 | } |
| 295 | |
| 296 | /// Get the operator precedence |
| 297 | /// use <https://www.postgresql.org/docs/7.2/sql-precedence.html> as a reference |