Don't panic on invalid where conditions, e.g. where 1
parent
4abec25949
commit
982873cf3d
|
@ -178,6 +178,14 @@ func (self *QueryParserSuite) TestParseDeleteQuery(c *C) {
|
|||
c.Assert(q.GetEndTime(), Equals, endTime)
|
||||
}
|
||||
|
||||
func (self *QueryParserSuite) TestInvalidWhereClause(c *C) {
|
||||
_, err := ParseQuery("delete from foo where 1;")
|
||||
c.Assert(err, NotNil)
|
||||
|
||||
_, err = ParseQuery("select * from foo where is_uppercase(name);")
|
||||
c.Assert(err, IsNil)
|
||||
}
|
||||
|
||||
func (self *QueryParserSuite) TestParseWithUnderscore(c *C) {
|
||||
queryString := "select _value, time, sequence_number from foo"
|
||||
query, err := ParseSelectQuery(queryString)
|
||||
|
|
|
@ -375,6 +375,15 @@ func getTime(condition *WhereCondition, isParsingStartTime bool) (*WhereConditio
|
|||
}
|
||||
|
||||
if expr, ok := condition.GetBoolExpression(); ok {
|
||||
switch expr.Type {
|
||||
case ValueDuration, ValueFloat, ValueInt, ValueString, ValueWildcard:
|
||||
return nil, ZERO_TIME, fmt.Errorf("Invalid where expression: %v", expr)
|
||||
}
|
||||
|
||||
if expr.Type == ValueFunctionCall {
|
||||
return condition, ZERO_TIME, nil
|
||||
}
|
||||
|
||||
leftValue := expr.Elems[0]
|
||||
isTimeOnLeft := leftValue.Type != ValueExpression && leftValue.Type != ValueFunctionCall
|
||||
rightValue := expr.Elems[1]
|
||||
|
|
Loading…
Reference in New Issue