Skip to content

Commit

Permalink
fix: added null safe operator precendence rule (#12307)
Browse files Browse the repository at this point in the history
Signed-off-by: Harshit Gangal <harshit@planetscale.com>
Co-authored-by: Harshit Gangal <harshit@planetscale.com>
  • Loading branch information
vitess-bot[bot] and harshit-gangal committed Feb 13, 2023
1 parent 85e505d commit cdae7f0
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion go/vt/sqlparser/precedence.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func precedenceFor(in Expr) Precendence {
return P12
case *ComparisonExpr:
switch node.Operator {
case EqualOp, NotEqualOp, GreaterThanOp, GreaterEqualOp, LessThanOp, LessEqualOp, LikeOp, InOp, RegexpOp:
case EqualOp, NotEqualOp, GreaterThanOp, GreaterEqualOp, LessThanOp, LessEqualOp, LikeOp, InOp, RegexpOp, NullSafeEqualOp:
return P11
}
case *IsExpr:
Expand Down
1 change: 1 addition & 0 deletions go/vt/sqlparser/precedence_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ func TestParens(t *testing.T) {
{in: "10 - 2 - 1", expected: "10 - 2 - 1"},
{in: "(10 - 2) - 1", expected: "10 - 2 - 1"},
{in: "10 - (2 - 1)", expected: "10 - (2 - 1)"},
{in: "0 <=> (1 and 0)", expected: "0 <=> (1 and 0)"},
}

for _, tc := range tests {
Expand Down

0 comments on commit cdae7f0

Please sign in to comment.