Change Wild to Wildcard and move test

pull/1170/head
David Norton 2014-11-25 18:23:10 -05:00
parent f8073bf287
commit 26ecd06ef5
3 changed files with 16 additions and 17 deletions

View File

@ -47,7 +47,7 @@ func (_ *TimeLiteral) node() {}
func (_ *DurationLiteral) node() {}
func (_ *BinaryExpr) node() {}
func (_ *ParenExpr) node() {}
func (_ *Wild) node() {}
func (_ *Wildcard) node() {}
// Query represents a collection of order statements.
type Query struct {
@ -86,7 +86,7 @@ func (_ *TimeLiteral) expr() {}
func (_ *DurationLiteral) expr() {}
func (_ *BinaryExpr) expr() {}
func (_ *ParenExpr) expr() {}
func (_ *Wild) expr() {}
func (_ *Wildcard) expr() {}
// Source represents a source of data for a statement.
type Source interface {
@ -236,9 +236,8 @@ type ParenExpr struct {
Expr Expr
}
// Wild represents a wild card expression.
type Wild struct {
Val string
// Wildcard represents a wild card expression.
type Wildcard struct {
}
// Visitor can be called by Walk to traverse an AST hierarchy.

View File

@ -265,7 +265,7 @@ func (p *Parser) parseFields() (Fields, error) {
// Check for "*" (i.e., "all fields")
if tok, _, _ := p.scanIgnoreWhitespace(); tok == MUL {
fields = append(fields, &Field{&Wild{"*"}, ""})
fields = append(fields, &Field{&Wildcard{}, ""})
return fields, nil
}
p.unscan()

View File

@ -9,17 +9,6 @@ import (
"github.com/influxdb/influxdb/influxql"
)
// Ensure the parser can parse a SELECT * query.
func TestParser_ParseQuery_SelectStar(t *testing.T) {
s := `SELECT * FROM b; SELECT c FROM d`
q, err := influxql.NewParser(strings.NewReader(s)).ParseQuery()
if err != nil {
t.Fatalf("unexpected error: %s", err)
} else if len(q.Statements) != 2 {
t.Fatalf("unexpected statement count: %d", len(q.Statements))
}
}
// Ensure the parser can parse a multi-statement query.
func TestParser_ParseQuery(t *testing.T) {
s := `SELECT a FROM b; SELECT c FROM d`
@ -56,6 +45,17 @@ func TestParser_ParseStatement(t *testing.T) {
stmt influxql.Statement
err string
}{
// SELECT * statement
{
s: `SELECT * FROM myseries`,
stmt: &influxql.SelectStatement{
Fields: influxql.Fields{
&influxql.Field{Expr: &influxql.Wildcard{}},
},
Source: &influxql.Series{Name: "myseries"},
},
},
// SELECT statement
{
s: `SELECT field1, field2 ,field3 AS field_x FROM myseries WHERE host = 'hosta.influxdb.org' GROUP BY 10h LIMIT 20 ORDER BY ASC;`,