Skip to content
This repository was archived by the owner on Jan 28, 2021. It is now read-only.

Commit 99dc027

Browse files
committed
Updated IsTrue to use the new Expression interface (TransformUp -> WithChildren)
Signed-off-by: Zach Musgrave <[email protected]>
1 parent ded9391 commit 99dc027

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

sql/expression/istrue.go

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
package expression
22

3-
import "github.com/src-d/go-mysql-server/sql"
3+
import (
4+
"errors"
5+
"github.com/src-d/go-mysql-server/sql"
6+
)
47

58
// IsTrue is an expression that checks if an expression is true.
69
type IsTrue struct {
@@ -62,15 +65,14 @@ func (e *IsTrue) String() string {
6265
return e.Child.String() + " " + isStr
6366
}
6467

65-
// TransformUp implements the Expression interface.
66-
func (e *IsTrue) TransformUp(f sql.TransformExprFunc) (sql.Expression, error) {
67-
child, err := e.Child.TransformUp(f)
68-
if err != nil {
69-
return nil, err
68+
// WithChildren implements the Expression interface.
69+
func (e *IsTrue) WithChildren(children ...sql.Expression) (sql.Expression, error) {
70+
if len(children) != 1 {
71+
return nil, errors.New("incorrect number of children")
7072
}
73+
7174
if e.invert {
72-
return f(NewIsFalse(child))
75+
return NewIsFalse(children[0]), nil
7376
}
74-
return f(NewIsTrue(child))
77+
return NewIsTrue(children[0]), nil
7578
}
76-

0 commit comments

Comments
 (0)