Skip to content

Commit

Permalink
parser: ast/expressions.go: IsNullExpr (pingcap#72)
Browse files Browse the repository at this point in the history
  • Loading branch information
lovewin99 authored and leoppro committed Dec 8, 2018
1 parent 30aca86 commit f39a9bb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
3 changes: 2 additions & 1 deletion ast/expressions.go
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,8 @@ type IsNullExpr struct {

// Restore implements Recoverable interface.
func (n *IsNullExpr) Restore(sb *strings.Builder) error {
return errors.New("Not implemented")
n.Format(sb)
return nil
}

// Format the ExprNode into a Writer.
Expand Down
8 changes: 8 additions & 0 deletions ast/expressions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,19 @@ func (tc *testExpressionsSuite) createTestCase4ColumnNameExpr() []exprTestCase {
}
}

func (tc *testExpressionsSuite) createTestCase4IsNullExpr() []exprTestCase {
return []exprTestCase{
{"select a is null", "SELECT `a` IS NULL"},
{"select a is not null", "SELECT `a` IS NOT NULL"},
}
}

func (tc *testExpressionsSuite) TestExpresionsRestore(c *C) {
parser := parser.New()
var testNodes []exprTestCase
testNodes = append(testNodes, tc.createTestCase4UnaryOperationExpr()...)
testNodes = append(testNodes, tc.createTestCase4ColumnNameExpr()...)
testNodes = append(testNodes, tc.createTestCase4IsNullExpr()...)

for _, node := range testNodes {
stmt, err := parser.ParseOneStmt(node.sourceSQL, "", "")
Expand Down

0 comments on commit f39a9bb

Please sign in to comment.