SetBit uses TimeFormat. Implements 315

This commit is contained in:
Yuce Tekol 2017-02-24 16:35:41 +03:00
parent 0242356849
commit 6f645b9db5
3 changed files with 4 additions and 5 deletions

View file

@ -493,7 +493,7 @@ func (e *Executor) executeSetBit(ctx context.Context, db string, c *pql.Call, op
var timestamp *time.Time
sTimestamp, ok := c.Args["timestamp"].(string)
if ok {
t, err := time.Parse("2006-01-02T15:04:05", sTimestamp)
t, err := time.Parse(TimeFormat, sTimestamp)
if err != nil {
return false, fmt.Errorf("invalid date: %s", sTimestamp)
}

View file

@ -399,7 +399,7 @@ func TestExecutor_Execute_Remote_SetBit_With_Timestamp(t *testing.T) {
s.Handler.Executor.ExecuteFn = func(ctx context.Context, db string, query *pql.Query, slices []uint64, opt *pilosa.ExecOptions) ([]interface{}, error) {
if db != `d` {
t.Fatalf("unexpected db: %s", db)
} else if query.String() != `SetBit(frame="f", id=10, profileID=2, timestamp="2016-12-11T10:09:07")` {
} else if query.String() != `SetBit(frame="f", id=10, profileID=2, timestamp="2016-12-11T10:09")` {
t.Fatalf("unexpected query: %s", query.String())
}
remoteCalled = true
@ -419,7 +419,7 @@ func TestExecutor_Execute_Remote_SetBit_With_Timestamp(t *testing.T) {
idx.DB("d").SetTimeQuantum("Y")
e := NewExecutor(idx.Index, c)
if _, err := e.Execute(context.Background(), "d", MustParse(`SetBit(id=10, frame=f, profileID=2, timestamp="2016-12-11T10:09:07")`), nil, nil); err != nil {
if _, err := e.Execute(context.Background(), "d", MustParse(`SetBit(id=10, frame=f, profileID=2, timestamp="2016-12-11T10:09")`), nil, nil); err != nil {
t.Fatal(err)
}

View file

@ -100,8 +100,7 @@ func (c *Call) String() string {
case []uint64:
fmt.Fprintf(&buf, "%v=%s", key, joinUint64Slice(v))
case time.Time:
layout := "2006-01-02T15:04:05"
fmt.Fprintf(&buf, "%v=\"%s\"", key, v.Format(layout))
fmt.Fprintf(&buf, "%v=\"%s\"", key, v.Format(TimeFormat))
default:
fmt.Fprintf(&buf, "%v=%v", key, v)
}