Repository navigation
fix: Round bound times to the nearest microsecond - #610
Merged
Merged
Conversation
Closes #605. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Hr1rd5PUWgaCJzotWt9NhJ
1 of 2 tasks
Member
Author
Accepted limitationsThe clean review found nothing above Low.
Generated by Claude Code |
krlmlr
marked this pull request as ready for review
November 29, 2026 12:06
This was referenced Nov 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #605.
Before this change,
set_time_buffer()truncated the fractional seconds of boundPOSIXctandhmsvalues. Because of floating-point representation,.000001was bound as.000000.Change
POSIXctorhmsvalue is rounded to a whole number of microseconds withllround(val * 1e6)before it is split into its parts.set_time_buffer()takes that 64-bit count and uses integer arithmetic only.DATETIME, the date comes from floor division of the count. A value that rounds up therefore carries into the next second, minute, hour and day, also for times before 1970.Datebinding is unchanged, since it usesfloor()on days.difftimevalues are converted tohmsin R first, so they take the fixed path.src/MariaRow.cppalready keeps microseconds, and is not touched.Tests
tests/testthat/test-bind-microseconds.R(new) coversdbBind()intoDATETIME(6)andTIME(6), and adbWriteTable()round trip. The cases are 1 µs and 999999 µs, a rollover to the next midnight, values before 1970, carries inhms, and negativehmsvalues. 4 of its 6 expectations fail without the fix. Local run against MariaDB 10.11 withNOT_CRAN=true: the whole suite had 0 failures and the onetest-timezone.Rerror ("US/Alaska" unknown to CCTZ in this container), which also happens onmain. MySQL was not tested: there is no server in this container, and CI's MySQL entries currently run MariaDB (#592).Found along the way
hmsvalues of 256 hours or more wrap around: Boundhmsvalues of 256 hours or more wrap around inTIMEcolumns #609, to be fixed in a PR stacked on this one.Session: https://claude.ai/code/session_01Hr1rd5PUWgaCJzotWt9NhJ
Generated by Claude Code