Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions go/vt/vtctl/grpcvtctldserver/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,13 @@ func valueToVTTime(s string) (*vttime.Time, error) {
return nil, nil
}

// Handle MySQL's zero/NULL timestamp (0000-00-00 00:00:00)
// This is what MySQL returns for NULL datetime values when the connection
// is not configured to return SQL NULL values.
if len(s) >= 10 && s[:10] == "0000-00-00" {
return nil, nil
}

gotime, err := time.ParseInLocation(sqltypes.TimestampFormat, s, time.Local)
if err != nil {
return nil, err
Expand Down
10 changes: 10 additions & 0 deletions go/vt/vtctl/grpcvtctldserver/query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,16 @@ func TestValueToVTTime(t *testing.T) {
value: "",
expected: nil,
},
{
name: "MySQL zero timestamp",
value: "0000-00-00 00:00:00",
expected: nil,
},
{
name: "MySQL zero timestamp with microseconds",
value: "0000-00-00 00:00:00.000000",
expected: nil,
},
{
name: "parse error",
value: "2006/01/02",
Expand Down
Loading