Fix up parser and handle new error message.
parent
e7c40e5cae
commit
344db8ff1e
|
@ -1023,7 +1023,9 @@ func (p *Parser) parseDropSeriesStatement() (*DropSeriesStatement, error) {
|
||||||
stmt := &DropSeriesStatement{}
|
stmt := &DropSeriesStatement{}
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
if tok, _, _ := p.scanIgnoreWhitespace(); tok == FROM {
|
tok, pos, lit := p.scanIgnoreWhitespace()
|
||||||
|
|
||||||
|
if tok == FROM {
|
||||||
// Parse source.
|
// Parse source.
|
||||||
if stmt.Source, err = p.parseSource(); err != nil {
|
if stmt.Source, err = p.parseSource(); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -1037,9 +1039,9 @@ func (p *Parser) parseDropSeriesStatement() (*DropSeriesStatement, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// If they didn't provide a FROM or a WHERE, they need to provide the SeriesID
|
// If they didn't provide a FROM or a WHERE, this query is invalid
|
||||||
if stmt.Condition == nil && stmt.Source == nil {
|
if stmt.Condition == nil && stmt.Source == nil {
|
||||||
return nil, fmt.Errorf("DROP SERIES requires a FROM or WHERE clause")
|
return nil, newParseError(tokstr(tok, lit), []string{"FROM", "WHERE"}, pos)
|
||||||
}
|
}
|
||||||
|
|
||||||
return stmt, nil
|
return stmt, nil
|
||||||
|
|
|
@ -717,10 +717,6 @@ func TestParser_ParseStatement(t *testing.T) {
|
||||||
},
|
},
|
||||||
|
|
||||||
// DROP SERIES statement
|
// DROP SERIES statement
|
||||||
{
|
|
||||||
s: `DROP SERIES 1`,
|
|
||||||
stmt: &influxql.DropSeriesStatement{SeriesID: 1},
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
s: `DROP SERIES FROM src`,
|
s: `DROP SERIES FROM src`,
|
||||||
stmt: &influxql.DropSeriesStatement{Source: &influxql.Measurement{Name: "src"}},
|
stmt: &influxql.DropSeriesStatement{Source: &influxql.Measurement{Name: "src"}},
|
||||||
|
@ -1158,7 +1154,7 @@ func TestParser_ParseStatement(t *testing.T) {
|
||||||
{s: `DELETE FROM`, err: `found EOF, expected identifier at line 1, char 13`},
|
{s: `DELETE FROM`, err: `found EOF, expected identifier at line 1, char 13`},
|
||||||
{s: `DELETE FROM myseries WHERE`, err: `found EOF, expected identifier, string, number, bool at line 1, char 28`},
|
{s: `DELETE FROM myseries WHERE`, err: `found EOF, expected identifier, string, number, bool at line 1, char 28`},
|
||||||
{s: `DROP MEASUREMENT`, err: `found EOF, expected identifier at line 1, char 18`},
|
{s: `DROP MEASUREMENT`, err: `found EOF, expected identifier at line 1, char 18`},
|
||||||
{s: `DROP SERIES`, err: `found EOF, expected number at line 1, char 13`},
|
{s: `DROP SERIES`, err: `found EOF, expected FROM, WHERE at line 1, char 13`},
|
||||||
{s: `DROP SERIES FROM`, err: `found EOF, expected identifier at line 1, char 18`},
|
{s: `DROP SERIES FROM`, err: `found EOF, expected identifier at line 1, char 18`},
|
||||||
{s: `DROP SERIES FROM src WHERE`, err: `found EOF, expected identifier, string, number, bool at line 1, char 28`},
|
{s: `DROP SERIES FROM src WHERE`, err: `found EOF, expected identifier, string, number, bool at line 1, char 28`},
|
||||||
{s: `SHOW CONTINUOUS`, err: `found EOF, expected QUERIES at line 1, char 17`},
|
{s: `SHOW CONTINUOUS`, err: `found EOF, expected QUERIES at line 1, char 17`},
|
||||||
|
@ -1530,10 +1526,6 @@ func TestDropSeriesStatement_String(t *testing.T) {
|
||||||
s string
|
s string
|
||||||
stmt influxql.Statement
|
stmt influxql.Statement
|
||||||
}{
|
}{
|
||||||
{
|
|
||||||
s: `DROP SERIES 1`,
|
|
||||||
stmt: &influxql.DropSeriesStatement{SeriesID: 1},
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
s: `DROP SERIES FROM src`,
|
s: `DROP SERIES FROM src`,
|
||||||
stmt: &influxql.DropSeriesStatement{Source: &influxql.Measurement{Name: "src"}},
|
stmt: &influxql.DropSeriesStatement{Source: &influxql.Measurement{Name: "src"}},
|
||||||
|
|
Loading…
Reference in New Issue