Skip to content

[MySQL] Fix encoding of negative fractional TIME values - #1772

Merged
tsegismont merged 1 commit into
eclipse-vertx:masterfrom
sharanggupta:mysql-negative-time-fraction
Nov 12, 2026
Merged

tsegismont merged 1 commit into
eclipse-vertx:masterfrom
sharanggupta:mysql-negative-time-fraction

Conversation

@sharanggupta

Copy link
Copy Markdown
Contributor

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.

@vietj vietj added this to the 5.3.0 milestone Oct 29, 2026
@tsegismont tsegismont changed the title Fix encoding of negative fractional TIME values [MySQL] Fix encoding of negative fractional TIME values Nov 12, 2026
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)
@tsegismont
tsegismont force-pushed the mysql-negative-time-fraction branch from 169f128 to ea31f07 Compare November 12, 2026 15:15
@tsegismont
tsegismont merged commit 39488ae into eclipse-vertx:master Nov 12, 2026
20 checks passed
tsegismont added a commit that referenced this pull request Nov 12, 2026
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.

Assisted-by: Anthropic Claude (claude-opus-5-5)


(cherry picked from commit 39488ae)

Signed-off-by: Sharang Gupta <sharang@sharanggupta.dev>
Signed-off-by: Thomas Segismont <tsegismont@gmail.com>
Co-authored-by: Sharang Gupta <sharang@sharanggupta.dev>
tsegismont added a commit that referenced this pull request Nov 12, 2026
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.

Assisted-by: Anthropic Claude (claude-opus-5-5)


(cherry picked from commit 39488ae)

Signed-off-by: Sharang Gupta <sharang@sharanggupta.dev>
Signed-off-by: Thomas Segismont <tsegismont@gmail.com>
Co-authored-by: Sharang Gupta <sharang@sharanggupta.dev>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants