Skip to content

Commit

Permalink
simplify code
Browse files Browse the repository at this point in the history
Signed-off-by: Florent Poinsard <[email protected]>
  • Loading branch information
frouioui committed Nov 27, 2023
1 parent ea40574 commit ec870a3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 13 deletions.
13 changes: 0 additions & 13 deletions go/vt/sqlparser/predicate_rewriting.go
Original file line number Diff line number Diff line change
Expand Up @@ -258,19 +258,6 @@ func ExtractINFromOR(expr *OrExpr) []Expr {
values = append(values, currentValues)
}

if len(varNames) == 1 {
var valueTuple ValTuple
for _, value := range values {
valueTuple = append(valueTuple, value[0])
}

return []Expr{&ComparisonExpr{
Operator: InOp,
Left: varNames[0],
Right: valueTuple,
}}
}

var nameTuple ValTuple
for _, name := range varNames {
nameTuple = append(nameTuple, name)
Expand Down
3 changes: 3 additions & 0 deletions go/vt/sqlparser/predicate_rewriting_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,9 @@ func TestExtractINFromOR(in *testing.T) {
}{{
in: "a = 1 and b = 41 or a = 2 and b = 42 or a = 3 and b = 43 or a = 4 and b = 44 or a = 5 and b = 45 or a = 6 and b = 46",
expected: "(a, b) in ((1, 41), (2, 42), (3, 43), (4, 44), (5, 45), (6, 46))",
}, {
in: "a = 1 or a = 2 or a = 3 or a = 4 or a = 5 or a = 6",
expected: "(a) in ((1), (2), (3), (4), (5), (6))",
}}

for _, tc := range tests {
Expand Down

0 comments on commit ec870a3

Please sign in to comment.