foldComparisonExpr folds a given comparison operation and its expressions into an equivalent operation that will hit in the CmpOps map, returning this new operation, along with potentially flipped operands and "flipped" and "not" flags.
( op ComparisonOperator, left, right Expr, )
| 4542 | // this new operation, along with potentially flipped operands and "flipped" |
| 4543 | // and "not" flags. |
| 4544 | func foldComparisonExpr( |
| 4545 | op ComparisonOperator, left, right Expr, |
| 4546 | ) (newOp ComparisonOperator, newLeft Expr, newRight Expr, flipped bool, not bool) { |
| 4547 | switch op { |
| 4548 | case NE: |
| 4549 | // NE(left, right) is implemented as !EQ(left, right). |
| 4550 | return EQ, left, right, false, true |
| 4551 | case GT: |
| 4552 | // GT(left, right) is implemented as LT(right, left) |
| 4553 | return LT, right, left, true, false |
| 4554 | case GE: |
| 4555 | // GE(left, right) is implemented as LE(right, left) |
| 4556 | return LE, right, left, true, false |
| 4557 | case NotIn: |
| 4558 | // NotIn(left, right) is implemented as !IN(left, right) |
| 4559 | return In, left, right, false, true |
| 4560 | case NotLike: |
| 4561 | // NotLike(left, right) is implemented as !Like(left, right) |
| 4562 | return Like, left, right, false, true |
| 4563 | case NotILike: |
| 4564 | // NotILike(left, right) is implemented as !ILike(left, right) |
| 4565 | return ILike, left, right, false, true |
| 4566 | case NotSimilarTo: |
| 4567 | // NotSimilarTo(left, right) is implemented as !SimilarTo(left, right) |
| 4568 | return SimilarTo, left, right, false, true |
| 4569 | case NotRegMatch: |
| 4570 | // NotRegMatch(left, right) is implemented as !RegMatch(left, right) |
| 4571 | return RegMatch, left, right, false, true |
| 4572 | case NotRegIMatch: |
| 4573 | // NotRegIMatch(left, right) is implemented as !RegIMatch(left, right) |
| 4574 | return RegIMatch, left, right, false, true |
| 4575 | case IsDistinctFrom: |
| 4576 | // IsDistinctFrom(left, right) is implemented as !IsNotDistinctFrom(left, right) |
| 4577 | // Note: this seems backwards, but IS NOT DISTINCT FROM is an extended |
| 4578 | // version of IS and IS DISTINCT FROM is an extended version of IS NOT. |
| 4579 | return IsNotDistinctFrom, left, right, false, true |
| 4580 | } |
| 4581 | return op, left, right, false, false |
| 4582 | } |
| 4583 | |
| 4584 | // hasUnescapedSuffix returns true if the ending byte is suffix and s has an |
| 4585 | // even number of escapeTokens preceding suffix. Otherwise hasUnescapedSuffix |
no outgoing calls
no test coverage detected
searching dependent graphs…