Don't emit the time condition for single point queries

Close #925
pull/671/merge
John Shahid 2014-11-05 17:02:41 -05:00
parent b5fb4840a9
commit 9507b187f1
3 changed files with 17 additions and 0 deletions

View File

@ -9,6 +9,8 @@
### Bugfixes
- [Issue #925](https://github.com/influxdb/influxdb/issues/925). Don't
generate invalid query strings for single point queries
- [Issue #1008](https://github.com/influxdb/influxdb/issues/1008). Return
an appropriate exit status code depending on whether the process exits
due to an error or exits gracefully.

View File

@ -190,6 +190,13 @@ func (self *SelectQuery) GetQueryString() string {
}
func (self *SelectQuery) GetQueryStringWithTimeCondition() string {
// if this is a single point query then it already has a time (and
// sequence number) condition; we don't need the extra (time < ???
// and time > ???) condition in the query string.
if self.IsSinglePointQuery() {
return self.GetQueryString()
}
return self.commonGetQueryStringWithTimes(true, true, self.startTime, self.endTime)
}

View File

@ -929,6 +929,14 @@ func (self *QueryParserSuite) TestParseSinglePointQuery(c *C) {
c.Assert(rightBoolExpression.Name, Equals, "=")
}
func (self *QueryParserSuite) TestSinglePointGetQueryString(c *C) {
qs := "select value from \"foo\" where (time = 999) AND (sequence_number = 1)"
q, err := ParseSelectQuery(qs)
c.Assert(err, IsNil)
c.Assert(q.GetQueryString(), Equals, qs)
c.Assert(q.GetQueryStringWithTimeCondition(), Equals, qs)
}
// TODO: test reversed order of time and sequence_number
func (self *QueryParserSuite) TestIsSinglePointQuery(c *C) {
query := "select * from foo where time = 123 and sequence_number = 99"