Skip to content

Commit

Permalink
expression: fix date format identifies '\n' as invalid separator (#32358
Browse files Browse the repository at this point in the history
)

close #32232
  • Loading branch information
mengxin9014 authored Feb 15, 2022
1 parent 167228a commit 2b9093f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
3 changes: 2 additions & 1 deletion types/time.go
Original file line number Diff line number Diff line change
Expand Up @@ -786,7 +786,8 @@ func isValidSeparator(c byte, prevParts int) bool {
return true
}

if prevParts == 2 && (c == ' ' || c == 'T') {
// for https://github.com/pingcap/tidb/issues/32232
if prevParts == 2 && (c == 'T' || c == ' ' || c == '\t' || c == '\n' || c == '\v' || c == '\f' || c == '\r') {
return true
}

Expand Down
5 changes: 5 additions & 0 deletions types/time_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1057,6 +1057,11 @@ func TestParseDateFormat(t *testing.T) {
{"T10:10:10", nil},
{"2011-11-11x", []string{"2011", "11", "11x"}},
{"xxx 10:10:10", nil},
{"2022-02-01\n16:33:00", []string{"2022", "02", "01", "16", "33", "00"}},
{"2022-02-01\f16:33:00", []string{"2022", "02", "01", "16", "33", "00"}},
{"2022-02-01\v16:33:00", []string{"2022", "02", "01", "16", "33", "00"}},
{"2022-02-01\r16:33:00", []string{"2022", "02", "01", "16", "33", "00"}},
{"2022-02-01\t16:33:00", []string{"2022", "02", "01", "16", "33", "00"}},
}

for _, tt := range tbl {
Expand Down

0 comments on commit 2b9093f

Please sign in to comment.