Skip to content

Commit

Permalink
Merge branch 'hotfix-0.1.8' into stable
Browse files Browse the repository at this point in the history
  • Loading branch information
hgouchet committed Jan 8, 2017
2 parents 30645cb + cd252ad commit 56c76d2
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
2 changes: 2 additions & 0 deletions parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ func (p *Parser) ParseShow() (ShowStmt, error) {
return nil, fmt.Errorf(ErrMsgSyntax, pattern)
}
stmt.With = pattern
stmt.UseWith = true
case STRING:
if clause == LIKE {
// Like clause can have a wildcard characters in the pattern.
Expand All @@ -239,6 +240,7 @@ func (p *Parser) ParseShow() (ShowStmt, error) {
stmt.Like = like
} else {
stmt.With = pattern
stmt.UseWith = true
}
default:
return nil, fmt.Errorf(ErrMsgSyntax, pattern)
Expand Down
15 changes: 13 additions & 2 deletions parser_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,15 +199,26 @@ func TestParser_ParseShow(t *testing.T) {
{
q: `SHOW TABLES WITH CampaignName;`,
stmt: &ShowStatement{
With: "CampaignName",
With: "CampaignName",
UseWith: true,
},
},

// Show statement with a specific column.
{
q: `SHOW TABLES WITH "CampaignName";`,
stmt: &ShowStatement{
With: "CampaignName",
With: "CampaignName",
UseWith: true,
},
},

// Show statement with no column.
{
q: `SHOW TABLES WITH "";`,
stmt: &ShowStatement{
With: "",
UseWith: true,
},
},

Expand Down
7 changes: 4 additions & 3 deletions statement.go
Original file line number Diff line number Diff line change
Expand Up @@ -269,8 +269,9 @@ type DescribeStmt interface {
// SHOW...FULL...TABLES...LIKE...WITH
type ShowStatement struct {
FullStatement
Like Pattern
With string
Like Pattern
With string
UseWith bool
Statement
}

Expand Down Expand Up @@ -312,5 +313,5 @@ func (s ShowStatement) LikePattern() (Pattern, bool) {
// WithColumnName returns the column name used to search table with this column.
// It implements the ShowStmt interface.
func (s ShowStatement) WithColumnName() (string, bool) {
return s.With, s.With != ""
return s.With, s.UseWith
}

0 comments on commit 56c76d2

Please sign in to comment.