Skip to content

Fix encoding of negative fractional TIME values - #1772

Open
sharanggupta wants to merge 1 commit into
eclipse-vertx:masterfrom
sharanggupta:mysql-negative-time-fraction
Open

sharanggupta wants to merge 1 commit into
eclipse-vertx:masterfrom
sharanggupta:mysql-negative-time-fraction

Conversation

@sharanggupta

Copy link
Copy Markdown

A negative Duration with a fraction is encoded by borrowing one second from the floored getSeconds(), so whenever that lands on a whole minute the second field becomes -1 and MySQL stores the wrong value: Duration.ofSeconds(-59).minusMillis(500) is read back as zero. The fields are now taken from the absolute duration with the sign sent separately. The test round-trips that value through a TIME(6) column.

Duration.getSeconds() is floored, so borrowing a second for the
fraction wrote second = -1 whenever the floored value was a whole
minute, and MySQL stored -59.5 seconds as zero.

Signed-off-by: Sharang Gupta <sharang@sharanggupta.dev>
Assisted-by: Anthropic Claude (claude-opus-5-5)
@vietj vietj added this to the 5.3.0 milestone Oct 29, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants