From 6f645b9db5649d85abf0a511227e20f72bb0e1c5 Mon Sep 17 00:00:00 2001 From: Yuce Tekol Date: Fri, 24 Feb 2017 16:35:41 +0300 Subject: [PATCH] SetBit uses TimeFormat. Implements 315 --- executor.go | 2 +- executor_test.go | 4 ++-- pql/ast.go | 3 +-- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/executor.go b/executor.go index c6c058244..19222cf51 100644 --- a/executor.go +++ b/executor.go @@ -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) } diff --git a/executor_test.go b/executor_test.go index 2cea37d3d..d51a9c996 100644 --- a/executor_test.go +++ b/executor_test.go @@ -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) } diff --git a/pql/ast.go b/pql/ast.go index dec73ac2b..3168e5ec0 100644 --- a/pql/ast.go +++ b/pql/ast.go @@ -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) }