Skip to content

[ruby] expose driver timestamp semantics - #1536

Merged
bgentry merged 1 commit into
masterfrom
bg/ruby-driver-time-contract
Oct 25, 2026
Merged

bgentry merged 1 commit into
masterfrom
bg/ruby-driver-time-contract

Conversation

@bgentry

@bgentry bgentry commented Oct 25, 2026

Copy link
Copy Markdown
Contributor

Driver consumers that compare persisted timestamps need the driver's normalization and precision rules without inspecting its database backend.

Add normalize_time and time_precision to the internal driver contract. Share normalization with SQL timestamp encoding and SQLite insertion formatting, preserving microsecond truncation on Postgres and millisecond rounding on SQLite. Both operations are public on driver instances so delegating wrappers can forward them.

@bgentry
bgentry requested a review from brandur October 25, 2026 02:22
@bgentry

bgentry commented Oct 25, 2026

Copy link
Copy Markdown
Contributor Author

@brandur minor addition to the driver interface to avoid driver-specific concepts getting pulled into the driver-agnostic layer, lmk your thoughts?

Driver consumers need to compare persisted timestamps without inspecting
which database backend encodes them. Private SQL helpers also cannot be
forwarded through delegating driver wrappers.

Expose `normalize_time` and `time_precision` on the internal driver
contract. Share normalization with SQL timestamp encoding and SQLite
insertion formatting, preserving microsecond truncation on Postgres and
millisecond rounding on SQLite. Return precision as an exact duration in
seconds.

Shared driver examples cover persisted queue and job timestamps at
precision boundaries, UTC conversion, delegation, and the smallest
representable increment across both adapters and database engines.
@bgentry
bgentry force-pushed the bg/ruby-driver-time-contract branch from 0eb23cb to fd87a0e Compare October 25, 2026 02:24

@brandur brandur left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wfm!

@bgentry
bgentry merged commit 00f12cd into master Oct 25, 2026
33 checks passed
@bgentry
bgentry deleted the bg/ruby-driver-time-contract branch October 25, 2026 04:43
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