Skip to content

Commit 4cd1cb3

Browse files
committed
tell go-mysql to leave those times alone
1 parent 7073bb7 commit 4cd1cb3

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

flow/connectors/mysql/cdc.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ func (c *MySqlConnector) startSyncer(ctx context.Context) (*replication.BinlogSy
235235
Logger: logger,
236236
Dialer: c.Dialer(),
237237
UseDecimal: true,
238-
ParseTime: true,
238+
ParseTime: false,
239239
TLSConfig: tlsConfig,
240240
}), nil
241241
}

flow/connectors/mysql/qvalue_convert.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -469,13 +469,13 @@ func QValueFromMysqlRowEvent(
469469
return types.QValueTime{Val: tm}, nil
470470
case types.QValueKindDate:
471471
if val == "0000-00-00" {
472-
return types.QValueDate{Val: time.Unix(0, 0)}, nil
472+
return types.QValueDate{Val: time.Unix(0, 0).UTC()}, nil
473473
}
474474
val, err := time.Parse(time.DateOnly, strings.ReplaceAll(val, "-00", "-01"))
475475
if err != nil {
476476
return nil, err
477477
}
478-
return types.QValueDate{Val: val}, nil
478+
return types.QValueDate{Val: val.UTC()}, nil
479479
case types.QValueKindTimestamp: // 0000-00-00 ends up here
480480
if mytype == mysql.MYSQL_TYPE_TIME || mytype == mysql.MYSQL_TYPE_TIME2 {
481481
tm, err := processTime(val)
@@ -485,13 +485,13 @@ func QValueFromMysqlRowEvent(
485485
return types.QValueTimestamp{Val: time.Unix(0, 0).UTC().Add(tm)}, nil
486486
}
487487
if strings.HasPrefix(val, "0000-00-00") {
488-
return types.QValueTimestamp{Val: time.Unix(0, 0)}, nil
488+
return types.QValueTimestamp{Val: time.Unix(0, 0).UTC()}, nil
489489
}
490490
tm, err := time.Parse("2006-01-02 15:04:05.999999", strings.ReplaceAll(val, "-00", "-01"))
491491
if err != nil {
492492
return nil, err
493493
}
494-
return types.QValueTimestamp{Val: tm}, nil
494+
return types.QValueTimestamp{Val: tm.UTC()}, nil
495495
}
496496
}
497497
return nil, fmt.Errorf("unexpected type %T for mysql type %d, qkind %s", val, mytype, qkind)

0 commit comments

Comments
 (0)