Skip to content

Commit

Permalink
expression: support %r and %T format for `STR_ ... (#19474) (#19693)
Browse files Browse the repository at this point in the history
  • Loading branch information
ti-srebot authored Sep 2, 2020
1 parent fcb4274 commit 6646c67
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions executor/executor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4163,6 +4163,10 @@ func (s *testSuiteP2) TestStrToDateBuiltin(c *C) {
tk.MustQuery(`select str_to_date('18+10+22','%y+%m+%d') from dual`).Check(testkit.Rows("2018-10-22"))
tk.MustQuery(`select str_to_date('18=10=22','%y=%m=%d') from dual`).Check(testkit.Rows("2018-10-22"))
tk.MustQuery(`select str_to_date('18_10_22','%y_%m_%d') from dual`).Check(testkit.Rows("2018-10-22"))
tk.MustQuery(`SELECT STR_TO_DATE('2020-07-04 11:22:33 PM', '%Y-%m-%d %r')`).Check(testkit.Rows("2020-07-04 23:22:33"))
tk.MustQuery(`SELECT STR_TO_DATE('2020-07-04 12:22:33 AM', '%Y-%m-%d %r')`).Check(testkit.Rows("2020-07-04 00:22:33"))
tk.MustQuery(`SELECT STR_TO_DATE('2020-07-04 12:22:33', '%Y-%m-%d %T')`).Check(testkit.Rows("2020-07-04 12:22:33"))
tk.MustQuery(`SELECT STR_TO_DATE('2020-07-04 00:22:33', '%Y-%m-%d %T')`).Check(testkit.Rows("2020-07-04 00:22:33"))
}

func (s *testSuiteP2) TestReadPartitionedTable(c *C) {
Expand Down
2 changes: 1 addition & 1 deletion types/time.go
Original file line number Diff line number Diff line change
Expand Up @@ -2636,7 +2636,7 @@ func GetFormatType(format string) (isDuration, isDate bool) {
}
if len(token) >= 2 && token[0] == '%' {
switch token[1] {
case 'h', 'H', 'i', 'I', 's', 'S', 'k', 'l', 'f':
case 'h', 'H', 'i', 'I', 's', 'S', 'k', 'l', 'f', 'r', 'T':
isDuration = true
case 'y', 'Y', 'm', 'M', 'c', 'b', 'D', 'd', 'e':
isDate = true
Expand Down

0 comments on commit 6646c67

Please sign in to comment.