-
Notifications
You must be signed in to change notification settings - Fork 1k
replication: return string when datetime's day or month is 00 #1047
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
MySQL supports 0 for day/month when this is an unknown value This cannot be encoded into a time.Time, where time.Date normalizes these 0s (so 2000-00-00 would become 1999-11-30) Pass these values through in their raw string form instead
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR updates datetime decoding to preserve zero-valued months or days by returning raw strings instead of normalizing via time.Time
.
- Introduces a
parseTime
flag indecodeDatetime2
andRowsEvent.decodeValue
to control string fallback for00
month/day. - Renames
formatBeforeUnixZeroTime
toformatDatetime
for unified formatting. - Adds new tests covering zero‐month/day behavior and adjusts the test harness to iterate parse settings.
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
File | Description |
---|---|
replication/time.go | Renamed formatBeforeUnixZeroTime to formatDatetime . |
replication/row_event.go | Updated decodeValue and decodeDatetime2 to use parseTime ; handle month==0 /day==0 by string. |
replication/row_event_test.go | Extended TestDecodeDatetime2 to loop over both parseTime modes and test zero-month/day cases. |
Comments suppressed due to low confidence (1)
replication/row_event_test.go:689
- Add test cases with fractional seconds (dec > 0) when month or day is zero to verify that fractional parts are preserved in the string output.
for _, parseTime := range []bool{true, false} {
Thanks! I'll start review about 24hrs later. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems fine. But I only glanced over it.
requires go-mysql-org/go-mysql#1047 to fix CDC
MySQL supports 0 for day/month when this is an unknown value
This cannot be encoded into a time.Time, where time.Date normalizes these 0s (so 2000-00-00 would become 1999-11-30)
Pass these values through in their raw string form instead, like we do for 0000-00-00