fix #398. Support now() and NOW() in the query lang
parent
1967629f16
commit
845afb58a4
|
@ -356,3 +356,5 @@
|
|||
This should be a backward compatible change, but is here for documentation only
|
||||
|
||||
### Bugfixes
|
||||
|
||||
- [Issue #398](https://github.com/influxdb/influxdb/issues/398). Support now() and NOW() in the query lang
|
||||
|
|
|
@ -239,7 +239,7 @@ func parseTimeString(t string) (*time.Time, error) {
|
|||
// parse time expressions, e.g. now() - 1d
|
||||
func parseTime(value *Value) (int64, error) {
|
||||
if value.Type != ValueExpression {
|
||||
if value.IsFunctionCall() && value.Name == "now" {
|
||||
if value.IsFunctionCall() && strings.ToLower(value.Name) == "now" {
|
||||
return time.Now().UnixNano(), nil
|
||||
}
|
||||
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
package parser
|
||||
|
||||
import (
|
||||
. "launchpad.net/gocheck"
|
||||
"math"
|
||||
"time"
|
||||
. "launchpad.net/gocheck"
|
||||
)
|
||||
|
||||
type QueryApiSuite struct{}
|
||||
|
@ -26,6 +26,7 @@ func (self *QueryApiSuite) TestWillReturnSingleSeries(c *C) {
|
|||
func (self *QueryApiSuite) TestGetStartTime(c *C) {
|
||||
for _, queryStr := range []string{
|
||||
"select * from t where time > now() - 1d and time < now() - 1h;",
|
||||
"select * from t where time > NOW() - 1d and time < NOW() - 1h;",
|
||||
"select * from t where now() - 1d < time and time < now() - 1h;",
|
||||
} {
|
||||
query, err := ParseSelectQuery(queryStr)
|
||||
|
|
Loading…
Reference in New Issue