Skip to content

Commit c5a4dd2

Browse files
committed
reverted base null time
1 parent 7ba45c5 commit c5a4dd2

File tree

2 files changed

+4
-8
lines changed

2 files changed

+4
-8
lines changed

utils.go

+2-7
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
package mysql
1010

1111
import (
12-
"bytes"
1312
"crypto/tls"
1413
"database/sql"
1514
"database/sql/driver"
@@ -107,15 +106,11 @@ func readBool(input string) (value bool, valid bool) {
107106
* Time related utils *
108107
******************************************************************************/
109108

110-
var (
111-
nullTimeBaseStr = "0000-00-00 00:00:00.000000"
112-
nullTimeBaseByte = []byte(nullTimeBaseStr)
113-
)
114-
115109
func parseDateTime(b []byte, loc *time.Location) (time.Time, error) {
110+
const base = "0000-00-00 00:00:00.000000"
116111
switch len(b) {
117112
case 10, 19, 21, 22, 23, 24, 25, 26: // up to "YYYY-MM-DD HH:MM:SS.MMMMMM"
118-
if bytes.Compare(b, nullTimeBaseByte[:len(b)]) == 0 {
113+
if string(b) == base[:len(b)] {
119114
return time.Time{}, nil
120115
}
121116

utils_test.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -295,9 +295,10 @@ func TestIsolationLevelMapping(t *testing.T) {
295295
}
296296

297297
func deprecatedParseDateTime(str string, loc *time.Location) (t time.Time, err error) {
298+
const base = "0000-00-00 00:00:00.000000"
298299
switch len(str) {
299300
case 10, 19, 21, 22, 23, 24, 25, 26: // up to "YYYY-MM-DD HH:MM:SS.MMMMMM"
300-
if str == nullTimeBaseStr[:len(str)] {
301+
if str == base[:len(str)] {
301302
return
302303
}
303304
if loc == time.UTC {

0 commit comments

Comments
 (0)