Skip to content

Commit

Permalink
builtin/time: Add tests for CURRENT_TIME(), CURTIME()
Browse files Browse the repository at this point in the history
  • Loading branch information
chenyanzhe committed Dec 20, 2015
1 parent 1b0c2e3 commit 2184577
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
9 changes: 9 additions & 0 deletions expression/builtin/time_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -275,3 +275,12 @@ func (s *testBuiltinSuite) TestCurrentDate(c *C) {
c.Assert(ok, IsTrue)
c.Assert(n.String(), GreaterEqual, last.Format(mysql.DateFormat))
}

func (s *testBuiltinSuite) TestCurrentTime(c *C) {
last := time.Now()
v, err := builtinCurrentTime(nil, nil)
c.Assert(err, IsNil)
n, ok := v.(mysql.Time)
c.Assert(ok, IsTrue)
c.Assert(n.String(), GreaterEqual, last.Format(mysql.CurrentTimeFormat))
}
8 changes: 4 additions & 4 deletions mysql/time.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ var (

// Time format without fractional seconds precision.
const (
DateFormat = "2006-01-02"
CurtimeFormat = "15:04:05"
TimeFormat = "2006-01-02 15:04:05"
DateFormat = "2006-01-02"
CurrentTimeFormat = "15:04:05"
TimeFormat = "2006-01-02 15:04:05"
// TimeFSPFormat is time format with fractional seconds precision.
TimeFSPFormat = "2006-01-02 15:04:05.000000"
)
Expand Down Expand Up @@ -127,7 +127,7 @@ func (t Time) String() string {
}

if t.Type == TypeDuration {
return t.Time.Format(CurtimeFormat)
return t.Time.Format(CurrentTimeFormat)
}

tfStr := TimeFormat
Expand Down

0 comments on commit 2184577

Please sign in to comment.