Skip to content

Commit

Permalink
stmts: ShowStmt uses SetCondition to binds like or where
Browse files Browse the repository at this point in the history
  • Loading branch information
siddontang committed Sep 28, 2015
1 parent a1a6ce5 commit 49ae949
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
10 changes: 10 additions & 0 deletions stmt/stmts/show.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,13 @@ func (s *ShowStmt) getDBName(ctx context.Context) string {
// if s.DBName is empty, we should use current db name if possible.
return db.GetCurrentSchema(ctx)
}

// SetCondition binds like or where expression.
func (s *ShowStmt) SetCondition(expr interface{}) {
switch x := expr.(type) {
case *expression.PatternLike:
s.Pattern = x
case expression.Expression:
s.Where = x
}
}
1 change: 1 addition & 0 deletions stmt/stmts/show_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,5 @@ func (s *testStmtSuite) TestShow(c *C) {
c.Assert(stmtList, HasLen, 1)
testStmt, ok = stmtList[0].(*stmts.ShowStmt)
c.Assert(ok, IsTrue)
c.Assert(testStmt.Pattern, NotNil)
}

0 comments on commit 49ae949

Please sign in to comment.